Marthee commited on
Commit
2e2005b
·
verified ·
1 Parent(s): e3e0aa7

Update Code_2_7.py

Browse files
Files changed (1) hide show
  1. Code_2_7.py +35 -11
Code_2_7.py CHANGED
@@ -847,7 +847,7 @@ def get_hatched_areas(datadoc,filename,FinalRatio,rotationangle,SearchArray):
847
  # rgb_color = get_hatch_color(entity) # Assuming this function exists
848
  unique_shapes.append((normalized_vertices, area1))
849
 
850
- if length > 0.6:
851
  hatched_areas.append([vertices, area1, length, rgb_color])
852
 
853
  elif str(path.type) == 'BoundaryPathType.EDGE' or path.type == 2:
@@ -897,7 +897,7 @@ def get_hatched_areas(datadoc,filename,FinalRatio,rotationangle,SearchArray):
897
  # rgb_color = get_hatch_color(entity) # Assuming this function exists
898
  unique_shapes.append((normalized_vertices, area1))
899
 
900
- if length > 0.6:
901
  hatched_areas.append([vert, area1, length, rgb_color])
902
 
903
  else:
@@ -1559,10 +1559,10 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,Thickness,pdfpa
1559
 
1560
  # Divide the shapePerimeter into two halves
1561
  half_index = len(shapeePerimeter) // 2
1562
- # half1 = shapeePerimeter[1:half_index+1]
1563
- # half2 = shapeePerimeter[half_index:]
1564
- half1 = shapeePerimeter[1:half_index]
1565
- half2 = shapeePerimeter[half_index:-1]
1566
 
1567
 
1568
 
@@ -1590,11 +1590,35 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,SearchArray,Thickness,pdfpa
1590
  chosen_end = end_point2
1591
  annot12 = page2.add_line_annot(chosen_start, chosen_end)
1592
  elif max_distance == half1_distance:
1593
- # Draw the polyline annotation for half1
1594
- annot12 = page2.add_polyline_annot(half1)
1595
- # else: # max_distance == half2_distance
1596
- # # Draw the polyline annotation for half2
1597
- # annot12 = page2.add_polyline_annot(half2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
 
1599
 
1600
 
 
847
  # rgb_color = get_hatch_color(entity) # Assuming this function exists
848
  unique_shapes.append((normalized_vertices, area1))
849
 
850
+ if length > 1:
851
  hatched_areas.append([vertices, area1, length, rgb_color])
852
 
853
  elif str(path.type) == 'BoundaryPathType.EDGE' or path.type == 2:
 
897
  # rgb_color = get_hatch_color(entity) # Assuming this function exists
898
  unique_shapes.append((normalized_vertices, area1))
899
 
900
+ if length > 1:
901
  hatched_areas.append([vert, area1, length, rgb_color])
902
 
903
  else:
 
1559
 
1560
  # Divide the shapePerimeter into two halves
1561
  half_index = len(shapeePerimeter) // 2
1562
+ half1 = shapeePerimeter[1:half_index+1]
1563
+ half2 = shapeePerimeter[half_index:]
1564
+ # half1 = shapeePerimeter[1:half_index]
1565
+ # half2 = shapeePerimeter[half_index:-1]
1566
 
1567
 
1568
 
 
1590
  chosen_end = end_point2
1591
  annot12 = page2.add_line_annot(chosen_start, chosen_end)
1592
  elif max_distance == half1_distance:
1593
+ # annot12 = page2.add_polyline_annot(half1)
1594
+ max_pair_distance = 0.0
1595
+ max_pair_start = None
1596
+ max_pair_end = None
1597
+
1598
+ # 2. Loop through each consecutive pair in half1
1599
+ for i in range(len(half1) - 1):
1600
+ p_current = half1[i]
1601
+ p_next = half1[i + 1]
1602
+
1603
+ # 3. Compute distance between these two points
1604
+ dist = calculate_distance(p_current, p_next)
1605
+
1606
+ # 4. Update max if this distance is greater
1607
+ if dist > max_pair_distance:
1608
+ max_pair_distance = dist
1609
+ max_pair_start = p_current
1610
+ max_pair_end = p_next
1611
+
1612
+ # 5. After the loop, max_pair_start and max_pair_end represent
1613
+ # the two consecutive points with the greatest separation.
1614
+ if max_pair_start is not None and max_pair_end is not None:
1615
+ # 6. Draw the line annotation using these two points
1616
+ annot12 = page2.add_line_annot(max_pair_start, max_pair_end)
1617
+ # print(f"Drew line annotation between {max_pair_start} and {max_pair_end}")
1618
+ else:
1619
+ # This case only occurs if half1 has fewer than 2 points
1620
+ print("Not enough points in half1 to compute a line.")
1621
+
1622
 
1623
 
1624