Marthee commited on
Commit
cca8ff8
·
verified ·
1 Parent(s): 84c2bd7

Upload 5 files

Browse files
Files changed (5) hide show
  1. Code_2_7.py +60 -7
  2. Legend_Detection.py +85 -7
  3. app.py +0 -0
  4. deploying_3_3.py +2 -2
  5. dxf__omar3_2.py +4 -8
Code_2_7.py CHANGED
@@ -236,7 +236,7 @@ def generate_annotation_xml_block(vertices, area_text, author, custom_data: dict
236
  now = datetime.datetime.utcnow()
237
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
238
  creation_date = now.isoformat() + 'Z'
239
- id_str = "fitz-" + uuid.uuid4().hex[:4].upper()
240
 
241
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
242
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
@@ -453,7 +453,7 @@ def save_multiple_annotations_bax(annotations, output_path, column_order,pdfWidt
453
  for scale in scales:
454
  Resource = SubElement(GlobalResources, 'Resource')
455
  SubElement(Resource, 'ID').text = scale
456
- SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34a35176b085503c55847f22a80e2a4b7858ad7537e8dba7951ea2a5e330efc783e7fb983eae1c373c6fb5e498e842f577bcc6d872a014b00407848d87e310dd6a5170193552e40a33abfb0540139ace5ccff316188243844962d98c9d3134b297eba2f4255626d1dee06d3e200a4149cd47989ae0c99dd32fb8ebe0a8f7265dea3fb5b9bc7095d5950a9aface655b3575bf070d8b30f604438f6873'
457
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
458
 
459
  # print(f" Saved {len(annotations)} annotations to {output_path}")
@@ -1591,11 +1591,21 @@ def normalize_color(color):
1591
  def color_close_enough(c1, c2, threshold=10):
1592
  return all(abs(a - b) <= threshold for a, b in zip(c1, c2))
1593
 
1594
- def adjustannotations(OutputPdfStage1,text_with_positions):
1595
  input_pdf_path = OutputPdfStage1
1596
  output_pdf_path = "Final-WallsAdjusted.pdf"
1597
  annotations_data = []
1598
 
 
 
 
 
 
 
 
 
 
 
1599
  # Load the input PDF
1600
  pdf_bytes_io = BytesIO(OutputPdfStage1)
1601
 
@@ -1646,6 +1656,8 @@ def adjustannotations(OutputPdfStage1,text_with_positions):
1646
  (None, None)
1647
  )
1648
  matched_text, matched_nbs = matched_entry
 
 
1649
  combined = ""
1650
  if matched_text and matched_nbs:
1651
  combined = f"{matched_text} - {matched_nbs}"
@@ -1656,6 +1668,27 @@ def adjustannotations(OutputPdfStage1,text_with_positions):
1656
  if combined:
1657
  obj.update({NameObject("/T"): TextStringObject(combined)})
1658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1659
  # Update annotation dictionaries for measurement type
1660
  if subtype == "/Line" and obj.get("/Subj", "") == "Perimeter Measurement":
1661
  obj.update({
@@ -1690,6 +1723,8 @@ def adjustannotations(OutputPdfStage1,text_with_positions):
1690
  annot_color,
1691
  matched_text,
1692
  matched_nbs,
 
 
1693
  ])
1694
 
1695
 
@@ -2410,7 +2445,7 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,CorrectionRatio
2410
  # doc.save(OutputPdfStage1)
2411
  # OutputPdfStage2=adjustannotations(OutputPdfStage1,text_with_positions)
2412
  modified_pdf_data = doc.tobytes()
2413
- OutputPdfStage2 , annotations_data=adjustannotations(modified_pdf_data,text_with_positions)
2414
 
2415
  if (Thickness):
2416
 
@@ -2479,8 +2514,8 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,CorrectionRatio
2479
  R=str(r2)
2480
  G=str(g2)
2481
  B=str(b2)
2482
-
2483
- annotations.append(
2484
  {
2485
 
2486
  'vertices': shapeinvertices[0], # [[x,y],[x1,y1],[....]] position of ur markup
@@ -2489,13 +2524,31 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,CorrectionRatio
2489
  'custom_data': {'Specification':shapeinvertices[5]},#identify custom colums here as( Column name: Text to add )
2490
  'type_internal': 'Bluebeam.PDF.Annotations.AnnotationMeasurePerimeter',
2491
  'subject': 'Perimeter Measurement',
2492
- 'label':shapeinvertices[4],
2493
  'opacity': '0.7',#opacity of ur shape fill
2494
  'color': R+ ' '+G + ' '+B,# normalized (RGB --> R/255 G/255 B/255)
2495
  'linestyle': LinestyleTemplates['Dashed6'].format(w=2) # LineStyles as in BB ,this w is the linewidth
2496
 
2497
  }
2498
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2499
 
2500
 
2501
  column_order = ['Specification'] #specify here the custom columns in order
 
236
  now = datetime.datetime.utcnow()
237
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
238
  creation_date = now.isoformat() + 'Z'
239
+ id_str = generate_bb_objptr()# "fitz-" + uuid.uuid4().hex[:4].upper()
240
 
241
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
242
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
 
453
  for scale in scales:
454
  Resource = SubElement(GlobalResources, 'Resource')
455
  SubElement(Resource, 'ID').text = scale
456
+ SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34bb46d9c11642f15411fe89c03aa80ce161b5d6dda06f9f1e148aace330efc783e779983c6f843bca5ba3086353e8fe8eb618591c4a096be0206d3c6543746f64412a6c94cc35a656f7f381cdd87ce1b8aebbc200386318c7962dc405839f8c7fa43753e9f60e6f200c402b43234ca6e0d959b26ff0d0c1511fa77469fed4e6ea4a3aad2bed37f583545b3575bf051bd610e205c9766776'
457
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
458
 
459
  # print(f" Saved {len(annotations)} annotations to {output_path}")
 
1591
  def color_close_enough(c1, c2, threshold=10):
1592
  return all(abs(a - b) <= threshold for a, b in zip(c1, c2))
1593
 
1594
+ def adjustannotations(OutputPdfStage1,text_with_positions,CollectedColors):
1595
  input_pdf_path = OutputPdfStage1
1596
  output_pdf_path = "Final-WallsAdjusted.pdf"
1597
  annotations_data = []
1598
 
1599
+ paired_colors = []
1600
+ for i in range(0, len(CollectedColors), 2):
1601
+ name = CollectedColors[i] # take the current name
1602
+ color_list = CollectedColors[i+1] # take the next item as color list
1603
+ # convert each component to int
1604
+ color = tuple(int(c) for c in color_list)
1605
+ paired_colors.append([name, color])
1606
+
1607
+ CollectedColors = paired_colors
1608
+
1609
  # Load the input PDF
1610
  pdf_bytes_io = BytesIO(OutputPdfStage1)
1611
 
 
1656
  (None, None)
1657
  )
1658
  matched_text, matched_nbs = matched_entry
1659
+ print("1st entry nbs: " ,type(matched_nbs))
1660
+ print("1st entry text: ",type(matched_text))
1661
  combined = ""
1662
  if matched_text and matched_nbs:
1663
  combined = f"{matched_text} - {matched_nbs}"
 
1668
  if combined:
1669
  obj.update({NameObject("/T"): TextStringObject(combined)})
1670
 
1671
+
1672
+
1673
+
1674
+ if subtype in ["/Line", "/PolyLine", "/Polygon"] and raw_color:
1675
+ matched_entry2 = next(
1676
+ ((name,color) for name,color in CollectedColors if color_close_enough(annot_color,color)),
1677
+ (None, None)
1678
+ )
1679
+ matched_text2, matched_nbs2 = matched_entry2
1680
+ print("2nd entry nbs: " ,type(matched_nbs2))
1681
+ print("2nd entry text: ",type(matched_text2))
1682
+ combined = ""
1683
+ if matched_text2 and matched_nbs2:
1684
+ combined2 = f"{matched_text2} - {matched_nbs2}"
1685
+ elif matched_text:
1686
+ combined2 = str(matched_text2)
1687
+ elif matched_nbs:
1688
+ combined2 = str(matched_nbs2)
1689
+ if combined2:
1690
+ obj.update({NameObject("/T"): TextStringObject(combined2)})
1691
+
1692
  # Update annotation dictionaries for measurement type
1693
  if subtype == "/Line" and obj.get("/Subj", "") == "Perimeter Measurement":
1694
  obj.update({
 
1723
  annot_color,
1724
  matched_text,
1725
  matched_nbs,
1726
+ matched_text2,
1727
+ matched_nbs2,
1728
  ])
1729
 
1730
 
 
2445
  # doc.save(OutputPdfStage1)
2446
  # OutputPdfStage2=adjustannotations(OutputPdfStage1,text_with_positions)
2447
  modified_pdf_data = doc.tobytes()
2448
+ OutputPdfStage2 , annotations_data=adjustannotations(modified_pdf_data,text_with_positions,CollectedColors)
2449
 
2450
  if (Thickness):
2451
 
 
2514
  R=str(r2)
2515
  G=str(g2)
2516
  B=str(b2)
2517
+ if shapeinvertices[6]:
2518
+ annotations.append(
2519
  {
2520
 
2521
  'vertices': shapeinvertices[0], # [[x,y],[x1,y1],[....]] position of ur markup
 
2524
  'custom_data': {'Specification':shapeinvertices[5]},#identify custom colums here as( Column name: Text to add )
2525
  'type_internal': 'Bluebeam.PDF.Annotations.AnnotationMeasurePerimeter',
2526
  'subject': 'Perimeter Measurement',
2527
+ 'label':shapeinvertices[6],
2528
  'opacity': '0.7',#opacity of ur shape fill
2529
  'color': R+ ' '+G + ' '+B,# normalized (RGB --> R/255 G/255 B/255)
2530
  'linestyle': LinestyleTemplates['Dashed6'].format(w=2) # LineStyles as in BB ,this w is the linewidth
2531
 
2532
  }
2533
  )
2534
+
2535
+ else:
2536
+ annotations.append(
2537
+ {
2538
+
2539
+ 'vertices': shapeinvertices[0], # [[x,y],[x1,y1],[....]] position of ur markup
2540
+ 'text': str(shapeinvertices[2])+' m',
2541
+ 'author': 'ADR',
2542
+ 'custom_data': {'Specification':shapeinvertices[5]},#identify custom colums here as( Column name: Text to add )
2543
+ 'type_internal': 'Bluebeam.PDF.Annotations.AnnotationMeasurePerimeter',
2544
+ 'subject': 'Perimeter Measurement',
2545
+ 'label':shapeinvertices[4],
2546
+ 'opacity': '0.7',#opacity of ur shape fill
2547
+ 'color': R+ ' '+G + ' '+B,# normalized (RGB --> R/255 G/255 B/255)
2548
+ 'linestyle': LinestyleTemplates['Dashed6'].format(w=2) # LineStyles as in BB ,this w is the linewidth
2549
+
2550
+ }
2551
+ )
2552
 
2553
 
2554
  column_order = ['Specification'] #specify here the custom columns in order
Legend_Detection.py CHANGED
@@ -1,5 +1,5 @@
1
 
2
- """## Imports"""
3
  import sys
4
  import math
5
  import random
@@ -32,8 +32,8 @@ from ezdxf.colors import aci2rgb
32
  from ezdxf.math import OCS, Matrix44, Vec3, Vec2
33
 
34
  import pandas as pd
35
- import google_sheet_Legend
36
- import tsadropboxretrieval
37
 
38
  from PyPDF2 import PdfReader, PdfWriter
39
  from PyPDF2.generic import (
@@ -369,16 +369,61 @@ def calculate_distance(pt1, pt2):
369
  dy = pt2[1] - pt1[1]
370
  return math.hypot(dx, dy)
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  def Legend_Detection(datadoc,dxfile,SearchArray,pdf_content=0):
373
-
374
-
 
375
  doc = ezdxf.readfile(dxfile)
376
  doc.header['$MEASUREMENT'] = 1
377
  msp = doc.modelspace()
378
 
379
  text_with_positions = []
380
 
381
-
382
  # if pdf_content:
383
  # doc = fitz.open(stream=pdf_content, filetype="pdf")
384
  # else:
@@ -387,6 +432,10 @@ def Legend_Detection(datadoc,dxfile,SearchArray,pdf_content=0):
387
  if(SearchArray):
388
  for i in range(len(SearchArray)):
389
 
 
 
 
 
390
  if (SearchArray[i][0] and SearchArray[i][1] and SearchArray[i][2]):
391
  print("First IF")
392
  print("SearchArray[i][1] = ",SearchArray[i][0])
@@ -449,7 +498,7 @@ def Legend_Detection(datadoc,dxfile,SearchArray,pdf_content=0):
449
 
450
  # Append the detected result only once
451
  text_with_positions.append([text, textNBS, (x, y), detected_color])
452
-
453
 
454
  elif (SearchArray[i][0] and SearchArray[i][2]):
455
  print("Second IF")
@@ -561,4 +610,33 @@ def Legend_Detection(datadoc,dxfile,SearchArray,pdf_content=0):
561
 
562
 
563
  text_with_positions=filtered_results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  return text_with_positions
 
1
 
2
+ # """## Imports"""
3
  import sys
4
  import math
5
  import random
 
32
  from ezdxf.math import OCS, Matrix44, Vec3, Vec2
33
 
34
  import pandas as pd
35
+ # import google_sheet_Legend
36
+ # import tsadropboxretrieval
37
 
38
  from PyPDF2 import PdfReader, PdfWriter
39
  from PyPDF2.generic import (
 
369
  dy = pt2[1] - pt1[1]
370
  return math.hypot(dx, dy)
371
 
372
+ def dedupe_colors_preserve_order(hatchcolor):
373
+ seen = set()
374
+ unique = []
375
+ for item in hatchcolor:
376
+ # normalize to a tuple (handles [(r,g,b)], [r,g,b], or (r,g,b))
377
+ if isinstance(item, (list, tuple)) and len(item) == 1 and isinstance(item[0], (list, tuple)):
378
+ color = tuple(item[0])
379
+ else:
380
+ color = tuple(item) if not isinstance(item, tuple) else item
381
+ if color not in seen:
382
+ seen.add(color)
383
+ unique.append(color)
384
+ return unique
385
+
386
+ def remove_existing_colors(unique_colors, filtered_items):
387
+ # extract normalized colors from filtered_items (assumes color is last element)
388
+ filtered_set = set()
389
+ for row in filtered_items:
390
+ if not row:
391
+ continue
392
+ color = row[-1]
393
+ if color is None:
394
+ continue
395
+ # normalize: make tuple
396
+ if isinstance(color, (list, tuple)):
397
+ filtered_set.add(tuple(color))
398
+ else:
399
+ # unexpected type: try to convert
400
+ try:
401
+ filtered_set.add(tuple(color))
402
+ except Exception:
403
+ pass
404
+
405
+ # build new list preserving order, excluding any color that appears in filtered_set
406
+ result = []
407
+ for c in unique_colors:
408
+ # normalize unique color to tuple in case it is list-like
409
+ color_t = tuple(c) if not isinstance(c, tuple) else c
410
+ if color_t not in filtered_set:
411
+ result.append(color_t)
412
+ return result
413
+
414
+
415
+
416
  def Legend_Detection(datadoc,dxfile,SearchArray,pdf_content=0):
417
+
418
+ hatchColors=[]
419
+ FinalColors=[]
420
  doc = ezdxf.readfile(dxfile)
421
  doc.header['$MEASUREMENT'] = 1
422
  msp = doc.modelspace()
423
 
424
  text_with_positions = []
425
 
426
+
427
  # if pdf_content:
428
  # doc = fitz.open(stream=pdf_content, filetype="pdf")
429
  # else:
 
432
  if(SearchArray):
433
  for i in range(len(SearchArray)):
434
 
435
+ print("SearchArray[i][0] = ",SearchArray[i][0])
436
+ print("SearchArray[i][1] = ",SearchArray[i][1])
437
+ print("SearchArray[i][2] = ",SearchArray[i][2])
438
+
439
  if (SearchArray[i][0] and SearchArray[i][1] and SearchArray[i][2]):
440
  print("First IF")
441
  print("SearchArray[i][1] = ",SearchArray[i][0])
 
498
 
499
  # Append the detected result only once
500
  text_with_positions.append([text, textNBS, (x, y), detected_color])
501
+
502
 
503
  elif (SearchArray[i][0] and SearchArray[i][2]):
504
  print("Second IF")
 
610
 
611
 
612
  text_with_positions=filtered_results
613
+
614
+ for entity in msp:
615
+ if entity.dxftype() == 'HATCH':
616
+
617
+ for path in entity.paths:
618
+ rgb_color,index = get_hatch_color(entity)
619
+ hatchColors.append([rgb_color])
620
+
621
+ unique_colors = dedupe_colors_preserve_order(hatchColors)
622
+ unique_new = remove_existing_colors(unique_colors, text_with_positions)
623
+ for item in unique_new:
624
+ FinalColors.append(['Hatch',None,None,item])
625
+ text_with_positions.append(FinalColors)
626
+
627
+ flat = []
628
+ for item in text_with_positions:
629
+ if isinstance(item, list) and len(item) > 0 and isinstance(item[0], list):
630
+ flat.extend(item) # nested → expand it
631
+ else:
632
+ flat.append(item)
633
+
634
+ text_with_positions = flat
635
+
636
+
637
+
638
+ print(text_with_positions)
639
+
640
+
641
+
642
  return text_with_positions
app.py CHANGED
The diff for this file is too large to render. See raw diff
 
deploying_3_3.py CHANGED
@@ -262,7 +262,7 @@ def generate_annotation_xml_block(vertices, area_text, author, custom_data: dict
262
  now = datetime.datetime.utcnow()
263
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
264
  creation_date = now.isoformat() + 'Z'
265
- id_str = "fitz-" + uuid.uuid4().hex[:4].upper()
266
 
267
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
268
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
@@ -479,7 +479,7 @@ def save_multiple_annotations_bax(annotations, output_path, column_order,pdfWidt
479
  for scale in scales:
480
  Resource = SubElement(GlobalResources, 'Resource')
481
  SubElement(Resource, 'ID').text = scale
482
- SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34a35176b085503c55847f22a80e2a4b7858ad7537e8dba7951ea2a5e330efc783e7fb983eae1c373c6fb5e498e842f577bcc6d872a014b00407848d87e310dd6a5170193552e40a33abfb0540139ace5ccff316188243844962d98c9d3134b297eba2f4255626d1dee06d3e200a4149cd47989ae0c99dd32fb8ebe0a8f7265dea3fb5b9bc7095d5950a9aface655b3575bf070d8b30f604438f6873'
483
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
484
  return bax_xml
485
  """PDF to image"""
 
262
  now = datetime.datetime.utcnow()
263
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
264
  creation_date = now.isoformat() + 'Z'
265
+ id_str = generate_bb_objptr()# "fitz-" + uuid.uuid4().hex[:4].upper()
266
 
267
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
268
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
 
479
  for scale in scales:
480
  Resource = SubElement(GlobalResources, 'Resource')
481
  SubElement(Resource, 'ID').text = scale
482
+ SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34bb46d9c11642f15411fe89c03aa80ce161b5d6dda06f9f1e148aace330efc783e779983c6f843bca5ba3086353e8fe8eb618591c4a096be0206d3c6543746f64412a6c94cc35a656f7f381cdd87ce1b8aebbc200386318c7962dc405839f8c7fa43753e9f60e6f200c402b43234ca6e0d959b26ff0d0c1511fa77469fed4e6ea4a3aad2bed37f583545b3575bf051bd610e205c9766776'
483
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
484
  return bax_xml
485
  """PDF to image"""
dxf__omar3_2.py CHANGED
@@ -264,7 +264,7 @@ def generate_annotation_xml_block(vertices, area_text, author, custom_data: dict
264
  now = datetime.datetime.utcnow()
265
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
266
  creation_date = now.isoformat() + 'Z'
267
- id_str = "fitz-" + uuid.uuid4().hex[:4].upper()
268
 
269
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
270
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
@@ -481,7 +481,7 @@ def save_multiple_annotations_bax(annotations, output_path, column_order,pdfWidt
481
  for scale in scales:
482
  Resource = SubElement(GlobalResources, 'Resource')
483
  SubElement(Resource, 'ID').text = scale
484
- SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34a35176b085503c55847f22a80e2a4b7858ad7537e8dba7951ea2a5e330efc783e7fb983eae1c373c6fb5e498e842f577bcc6d872a014b00407848d87e310dd6a5170193552e40a33abfb0540139ace5ccff316188243844962d98c9d3134b297eba2f4255626d1dee06d3e200a4149cd47989ae0c99dd32fb8ebe0a8f7265dea3fb5b9bc7095d5950a9aface655b3575bf070d8b30f604438f6873'
485
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
486
  return bax_xml
487
  """PDF to image"""
@@ -1300,7 +1300,7 @@ def get_hatched_areas(datadoc,filename,FinalRatio,rotationangle,SearchArray):
1300
  width = maxx - minx
1301
  height = maxy - miny
1302
 
1303
- if (poly.area > 0.9 and (height > 0.7 and width > 0.7)):
1304
  area1 = round(poly.area, 3)
1305
  perimeter = round(poly.length, 3)
1306
  normalized_vertices = normalize_vertices(vert)
@@ -2015,14 +2015,10 @@ def gather_and_union_groups(
2015
  if len(verts) < 3:
2016
  continue
2017
  try:
2018
- poly = Polygon(verts)
2019
  if not poly.is_valid or poly.is_empty:
2020
  # try fix by buffering 0
2021
  poly = poly.buffer(0)
2022
- if isinstance(poly, MultiPolygon):
2023
- poly = max(poly, key=lambda p: p.area)
2024
-
2025
-
2026
  if poly.is_empty:
2027
  continue
2028
  polys.append(poly)
 
264
  now = datetime.datetime.utcnow()
265
  mod_date = now.strftime("D:%Y%m%d%H%M%S+00'00'")
266
  creation_date = now.isoformat() + 'Z'
267
+ id_str = generate_bb_objptr()# "fitz-" + uuid.uuid4().hex[:4].upper()
268
 
269
  vert_str = ' '.join([f'{x:.4f}' for point in vertices for x in point])
270
  ordered_column_values = [f'({custom_data.get(col, "")})' for col in column_order]
 
481
  for scale in scales:
482
  Resource = SubElement(GlobalResources, 'Resource')
483
  SubElement(Resource, 'ID').text = scale
484
+ SubElement(Resource, 'Raw').text = '789c85d04f0b82401005f0af3247bd34bb46d9c11642f15411fe89c03aa80ce161b5d6dda06f9f1e148aace330efc783e779983c6f843bca5ba3086353e8fe8eb618591c4a096be0206d3c6543746f64412a6c94cc35a656f7f381cdd87ce1b8aebbc200386318c7962dc405839f8c7fa43753e9f60e6f200c402b43234ca6e0d959b26ff0d0c1511fa77469fed4e6ea4a3aad2bed37f583545b3575bf051bd610e205c9766776'
485
  bax_xml= tostring(doc, encoding="unicode", method="xml") #tostring(doc, encoding="utf-8", method="xml").decode("utf-8")
486
  return bax_xml
487
  """PDF to image"""
 
1300
  width = maxx - minx
1301
  height = maxy - miny
1302
 
1303
+ if (poly.area > 0.1 and (height > 0.1 and width > 0.1)):
1304
  area1 = round(poly.area, 3)
1305
  perimeter = round(poly.length, 3)
1306
  normalized_vertices = normalize_vertices(vert)
 
2015
  if len(verts) < 3:
2016
  continue
2017
  try:
2018
+ poly = Polygon(verts)
2019
  if not poly.is_valid or poly.is_empty:
2020
  # try fix by buffering 0
2021
  poly = poly.buffer(0)
 
 
 
 
2022
  if poly.is_empty:
2023
  continue
2024
  polys.append(poly)