Update dxf__omar3_2.py
Browse files- dxf__omar3_2.py +100 -0
dxf__omar3_2.py
CHANGED
|
@@ -96,6 +96,9 @@ import uuid
|
|
| 96 |
from xml.etree.ElementTree import Element, SubElement, tostring, ElementTree
|
| 97 |
from xml.dom.minidom import parseString
|
| 98 |
|
|
|
|
|
|
|
|
|
|
| 99 |
"""## Notes"""
|
| 100 |
|
| 101 |
#new approach to get width and height of dxf plan
|
|
@@ -2315,7 +2318,104 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,pdfpath=0,pdfna
|
|
| 2315 |
annot14.set_opacity(0.7)
|
| 2316 |
annot14.update()
|
| 2317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2319 |
|
| 2320 |
page2.set_rotation(rotationOld)
|
| 2321 |
Correct_img=flip(imgg)
|
|
|
|
| 96 |
from xml.etree.ElementTree import Element, SubElement, tostring, ElementTree
|
| 97 |
from xml.dom.minidom import parseString
|
| 98 |
|
| 99 |
+
import colorsys
|
| 100 |
+
|
| 101 |
+
|
| 102 |
"""## Notes"""
|
| 103 |
|
| 104 |
#new approach to get width and height of dxf plan
|
|
|
|
| 2318 |
annot14.set_opacity(0.7)
|
| 2319 |
annot14.update()
|
| 2320 |
|
| 2321 |
+
|
| 2322 |
+
allvertices = annotations_data
|
| 2323 |
+
LinestyleTemplates = {
|
| 2324 |
+
'Solid': '<</W {w}/S/S/Type/Border>>',
|
| 2325 |
+
'Dashed1':'<</W {w}/S/D/D[2 2]/Type/Border>>',
|
| 2326 |
+
'Dashed2': '<</W {w}/S/D/D[3 3]/Type/Border>>',
|
| 2327 |
+
'Dashed3': '<</W {w}/S/D/D[4 4]/Type/Border>>',
|
| 2328 |
+
'Dashed4': '<</W {w}/S/D/D[4 3 2 3]/Type/Border>>',
|
| 2329 |
+
'Dashed5': '<</W {w}/S/D/D[4 3 16 3]/Type/Border>>',
|
| 2330 |
+
'Dashed6': '<</W {w}/S/D/D[8 4 4 4]/Type/Border>>'
|
| 2331 |
+
}
|
| 2332 |
+
#/BS<</W 1/S/D/D[4 4]/Type/Border>>
|
| 2333 |
+
|
| 2334 |
+
HatchFunctions = {
|
| 2335 |
+
'None':'',
|
| 2336 |
+
'Brick': setBrickHatch,
|
| 2337 |
+
'DiagonalBrick':setDiagonalBrickHatch,
|
| 2338 |
+
'Horizontal':setHorizontalHatch,
|
| 2339 |
+
'Vertical':setVerticalHatch,
|
| 2340 |
+
'DiagonalDown':setDiagonalDownHatch,
|
| 2341 |
+
'DiagonalUp':setDiagonalUpHatch,
|
| 2342 |
+
'Grid': setGridHatch,
|
| 2343 |
+
'Weave':setWeaveHatch,
|
| 2344 |
+
'10Dots':set10DotsHatch,
|
| 2345 |
+
'20Dots':set20DotsHatch,
|
| 2346 |
+
'30Dots':set30DotsHatch
|
| 2347 |
+
}
|
| 2348 |
+
|
| 2349 |
+
#Area and perimeter numbers example
|
| 2350 |
+
area = 1
|
| 2351 |
+
perimeter = 1
|
| 2352 |
+
|
| 2353 |
+
import colorsys
|
| 2354 |
+
|
| 2355 |
+
annotations=[]
|
| 2356 |
+
for shapeinvertices in allvertices:
|
| 2357 |
+
|
| 2358 |
+
rn=shapeinvertices[3][0]-150/255
|
| 2359 |
+
gn=shapeinvertices[3][1]-150/255
|
| 2360 |
+
bn=shapeinvertices[3][2]-150/255
|
| 2361 |
+
|
| 2362 |
+
h, s, v = colorsys.rgb_to_hsv(rn, gn, bn)
|
| 2363 |
+
|
| 2364 |
+
# snap to full saturation, 50% brightness
|
| 2365 |
+
s2, v2 = 0.6, 0.9
|
| 2366 |
+
|
| 2367 |
+
# back to RGB
|
| 2368 |
+
r2, g2, b2 = colorsys.hsv_to_rgb(h, s2, v2)
|
| 2369 |
+
print(r2,g2,b2)
|
| 2370 |
+
R=str(r2)
|
| 2371 |
+
G=str(g2)
|
| 2372 |
+
B=str(b2)
|
| 2373 |
+
print(R,G,B)
|
| 2374 |
+
r2, g2, b2 = colorsys.hsv_to_rgb(h, s2, v2)
|
| 2375 |
+
color_str = f"{r2:.3f} {g2:.3f} {b2:.3f}"
|
| 2376 |
+
hatch_color = f"{float(hatchcolorR):.0f} {float(hatchcolorG):.0f} {float(hatchcolorB):.0f}"
|
| 2377 |
+
print(color_str,hatch_color)
|
| 2378 |
+
if(shapeinvertices[1] is not None):
|
| 2379 |
+
|
| 2380 |
+
annotations.append(
|
| 2381 |
+
{
|
| 2382 |
+
|
| 2383 |
+
'vertices': shapeinvertices[0], # [[x,y],[x1,y1],[....]] position of ur markup
|
| 2384 |
+
'text': str(shapeinvertices[1])+' sq m',
|
| 2385 |
+
'author': 'ADR',
|
| 2386 |
+
'custom_data': {'Legend': shapeinvertices[4],'NBS':shapeinvertices[5]},#identify custom colums here as( Column name: Text to add )
|
| 2387 |
+
'type_internal': 'Bluebeam.PDF.Annotations.AnnotationMeasureArea',
|
| 2388 |
+
'subject': 'Area Measurement',
|
| 2389 |
+
'label': 'label',#change label to whatever u want
|
| 2390 |
+
'opacity': '0.5',#opacity of ur shape fill
|
| 2391 |
+
'color': color_str,# normalized (RGB --> R/255 G/255 B/255)
|
| 2392 |
+
'linestyle': LinestyleTemplates['Solid'].format(w=0),
|
| 2393 |
+
'hatchstyle': HatchFunctions['DiagonalDown'](color_str, hatch_color),#this is the hatchstyle and the hatch color fill and the hatch line color,
|
| 2394 |
+
#if u want the hatch to be none (as in a solid color only) just pass HatchFunctions['None'] without any colors here
|
| 2395 |
+
'hatchLinescolor':hatch_color,
|
| 2396 |
+
|
| 2397 |
+
|
| 2398 |
+
}
|
| 2399 |
+
)
|
| 2400 |
+
|
| 2401 |
+
|
| 2402 |
+
|
| 2403 |
+
|
| 2404 |
+
|
| 2405 |
+
column_order = ['Legend','NBS'] #specify here the custom columns in order
|
| 2406 |
+
# print(bax_annotations)
|
| 2407 |
+
|
| 2408 |
+
#replace with ur pdf width and height variables
|
| 2409 |
+
pdfWidth=1684
|
| 2410 |
+
pdfHeight=2384
|
| 2411 |
+
|
| 2412 |
|
| 2413 |
+
# save_multiple_annotations_bax(
|
| 2414 |
+
# bax_annotations, 'Area_Perimeter_OMAR_output.bax', column_order, pdfWidth, pdfHeight
|
| 2415 |
+
# )
|
| 2416 |
+
save_multiple_annotations_bax(
|
| 2417 |
+
annotations, 'FF-Ceiling.bax', column_order, pdfWidth, pdfHeight
|
| 2418 |
+
)
|
| 2419 |
|
| 2420 |
page2.set_rotation(rotationOld)
|
| 2421 |
Correct_img=flip(imgg)
|