feat(isogrid): Add DRAW_HOLES flag to skip bolt holes in NX import

Default: DRAW_HOLES = False (holes already exist in the solid body).

Config block in import_profile.py is now:
  DRAW_OUTER_BOUNDARY = False  (sandbox perimeter — not needed for subtract)
  DRAW_HOLES          = False  (bolt holes — already in existing body)

Sketch now imports ONLY the rib pocket profiles, ready for Subtract extrude.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 09:49:08 -05:00
parent 98774453b3
commit a9c40368d3

View File

@@ -44,6 +44,9 @@ DEFAULT_RIB_THICKNESS = 10.0 # mm, fallback if not in profile JSON
# Set to True only for standalone plate creation (no existing body). # Set to True only for standalone plate creation (no existing body).
DRAW_OUTER_BOUNDARY = False DRAW_OUTER_BOUNDARY = False
# Set to False to skip bolt hole circles (they already exist in the solid body).
DRAW_HOLES = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Geometry helpers # Geometry helpers
@@ -878,29 +881,32 @@ def main():
lister.WriteLine(f"[import] Pockets done: {total_lines} lines + {total_arcs} arcs") lister.WriteLine(f"[import] Pockets done: {total_lines} lines + {total_arcs} arcs")
# Holes (bolt circles) — drawn as two semicircular arcs each # Holes (bolt circles)
holes = profile.get("holes", []) if DRAW_HOLES:
if holes: holes = profile.get("holes", [])
holes_drawn = 0 if holes:
for hole in holes: holes_drawn = 0
try: for hole in holes:
cx, cy = hole["center"] try:
r = hole.get("radius", hole.get("diameter", 0) / 2.0) cx, cy = hole["center"]
p1 = [cx + r, cy] r = hole.get("radius", hole.get("diameter", 0) / 2.0)
p2 = [cx, cy + r] p1 = [cx + r, cy]
p3 = [cx - r, cy] p2 = [cx, cy + r]
p4 = [cx, cy - r] p3 = [cx - r, cy]
p1_3d = unproject_point_to_3d(p1, transform) p4 = [cx, cy - r]
p2_3d = unproject_point_to_3d(p2, transform) p1_3d = unproject_point_to_3d(p1, transform)
p3_3d = unproject_point_to_3d(p3, transform) p2_3d = unproject_point_to_3d(p2, transform)
p4_3d = unproject_point_to_3d(p4, transform) p3_3d = unproject_point_to_3d(p3, transform)
_draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d) p4_3d = unproject_point_to_3d(p4, transform)
_draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d) _draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d)
holes_drawn += 1 _draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d)
total_arcs += 2 holes_drawn += 1
except Exception as exc: total_arcs += 2
lister.WriteLine(f"[import] WARN: hole failed: {exc}") except Exception as exc:
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn ({holes_drawn*2} arcs)") lister.WriteLine(f"[import] WARN: hole failed: {exc}")
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn ({holes_drawn*2} arcs)")
else:
lister.WriteLine(f"[import] Holes skipped (DRAW_HOLES=False)")
lister.WriteLine(f"[import] Total: {total_lines} lines + {total_arcs} arcs") lister.WriteLine(f"[import] Total: {total_lines} lines + {total_arcs} arcs")
@@ -928,28 +934,29 @@ def main():
lister.WriteLine(f"[import] Done: {total_lines} lines in sketch") lister.WriteLine(f"[import] Done: {total_lines} lines in sketch")
# Holes for legacy fallback # Holes for legacy fallback
holes = profile.get("holes", []) if DRAW_HOLES:
if holes: holes = profile.get("holes", [])
holes_drawn = 0 if holes:
for hole in holes: holes_drawn = 0
try: for hole in holes:
cx, cy = hole["center"] try:
r = hole["diameter"] / 2.0 cx, cy = hole["center"]
p1 = [cx + r, cy] r = hole["diameter"] / 2.0
p2 = [cx, cy + r] p1 = [cx + r, cy]
p3 = [cx - r, cy] p2 = [cx, cy + r]
p1_3d = unproject_point_to_3d(p1, transform) p3 = [cx - r, cy]
p2_3d = unproject_point_to_3d(p2, transform) p1_3d = unproject_point_to_3d(p1, transform)
p3_3d = unproject_point_to_3d(p3, transform) p2_3d = unproject_point_to_3d(p2, transform)
_draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d) p3_3d = unproject_point_to_3d(p3, transform)
p4 = [cx, cy - r] _draw_arc_3pt(work_part, p1_3d, p2_3d, p3_3d)
p4_3d = unproject_point_to_3d(p4, transform) p4 = [cx, cy - r]
_draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d) p4_3d = unproject_point_to_3d(p4, transform)
holes_drawn += 1 _draw_arc_3pt(work_part, p3_3d, p4_3d, p1_3d)
total_lines += 2 # counting as arcs but reusing counter holes_drawn += 1
except Exception as exc: total_lines += 2
lister.WriteLine(f"[import] WARN: hole {hole.get('index','?')} failed: {exc}") except Exception as exc:
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn") lister.WriteLine(f"[import] WARN: hole {hole.get('index','?')} failed: {exc}")
lister.WriteLine(f"[import] Holes: {holes_drawn}/{len(holes)} drawn")
# Deactivate sketch # Deactivate sketch
try: try: