import_profile: draw bolt holes from rib profile JSON
Holes drawn as two 3-point arcs (semicircles) using center/diameter. Both structured and legacy pocket formats supported.
This commit is contained in:
@@ -903,6 +903,33 @@ def main():
|
||||
|
||||
lister.WriteLine(f"[import] Done: {total_lines} lines + {total_arcs} arcs in sketch")
|
||||
lister.WriteLine(f"[import] Expected: ~{len(pockets)*3} lines + ~{len(pockets)*3} arcs")
|
||||
|
||||
# Holes (bolt circles etc.)
|
||||
holes = profile.get("holes", [])
|
||||
if holes:
|
||||
holes_drawn = 0
|
||||
for hole in holes:
|
||||
try:
|
||||
cx, cy = hole["center"]
|
||||
r = hole["diameter"] / 2.0
|
||||
# Draw as circle: 3 points on circumference
|
||||
p1 = [cx + r, cy]
|
||||
p2 = [cx, cy + r]
|
||||
p3 = [cx - r, cy]
|
||||
p1_3d = unproject_point_to_3d(p1, transform)
|
||||
p2_3d = unproject_point_to_3d(p2, transform)
|
||||
p3_3d = unproject_point_to_3d(p3, transform)
|
||||
_draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d)
|
||||
# Second half of circle
|
||||
p4 = [cx, cy - r]
|
||||
p4_3d = unproject_point_to_3d(p4, transform)
|
||||
_draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d)
|
||||
holes_drawn += 1
|
||||
total_arcs += 2
|
||||
except Exception as exc:
|
||||
lister.WriteLine(f"[import] WARN: hole {hole.get('index','?')} failed: {exc}")
|
||||
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn ({holes_drawn*2} arcs)")
|
||||
|
||||
else:
|
||||
# Legacy format: pockets are point lists
|
||||
lister.WriteLine(f"[import] Legacy format: {len(pockets)} pocket polylines")
|
||||
@@ -924,6 +951,30 @@ def main():
|
||||
pass
|
||||
lister.WriteLine(f"[import] Done: {total_lines} lines in sketch")
|
||||
|
||||
# Holes (legacy path too)
|
||||
holes = profile.get("holes", [])
|
||||
if holes:
|
||||
holes_drawn = 0
|
||||
for hole in holes:
|
||||
try:
|
||||
cx, cy = hole["center"]
|
||||
r = hole["diameter"] / 2.0
|
||||
p1 = [cx + r, cy]
|
||||
p2 = [cx, cy + r]
|
||||
p3 = [cx - r, cy]
|
||||
p1_3d = unproject_point_to_3d(p1, transform)
|
||||
p2_3d = unproject_point_to_3d(p2, transform)
|
||||
p3_3d = unproject_point_to_3d(p3, transform)
|
||||
_draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d)
|
||||
p4 = [cx, cy - r]
|
||||
p4_3d = unproject_point_to_3d(p4, transform)
|
||||
_draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d)
|
||||
holes_drawn += 1
|
||||
total_lines += 2 # counting as arcs but reusing counter
|
||||
except Exception as exc:
|
||||
lister.WriteLine(f"[import] WARN: hole {hole.get('index','?')} failed: {exc}")
|
||||
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn")
|
||||
|
||||
# Deactivate sketch
|
||||
try:
|
||||
update_model, _ = _resolve_enum([
|
||||
|
||||
Reference in New Issue
Block a user