feat(isogrid): Skip outer boundary in NX sketch import (subtract workflow)

Add DRAW_OUTER_BOUNDARY flag (default: False) to import_profile.py.

When False (default): only pocket profiles + holes are imported into the
sketch. This is the correct mode when subtracting rib pockets from an
existing solid body — the sandbox perimeter is not needed and would create
unwanted edges in the part.

When True: full profile including sandbox perimeter (original behavior,
for standalone plate creation only).

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

View File

@@ -39,6 +39,11 @@ SKETCH_NAME_PREFIX = "ISOGRID_RIB_" # e.g., ISOGRID_RIB_sandbox_1
EXTRUDE_NAME_PREFIX = "ISOGRID_EXTRUDE_" # e.g., ISOGRID_EXTRUDE_sandbox_1
DEFAULT_RIB_THICKNESS = 10.0 # mm, fallback if not in profile JSON
# Set to False when importing into an existing solid body (subtract workflow).
# The outer boundary is not needed — only the pocket profiles and holes.
# Set to True only for standalone plate creation (no existing body).
DRAW_OUTER_BOUNDARY = False
# ---------------------------------------------------------------------------
# Geometry helpers
@@ -841,9 +846,8 @@ def main():
_clear_sketch_geometry(sketch, lister)
# --- Draw geometry ---
# Strategy: draw outer boundary + pocket outlines (lines+arcs) + holes
# NX sketch regions: the rib web is the area BETWEEN outer boundary
# and pocket/hole outlines. Extrude picks the rib material regions.
# DRAW_OUTER_BOUNDARY = False: only pockets + holes (subtract from existing body)
# DRAW_OUTER_BOUNDARY = True: full profile including sandbox perimeter
pockets = profile.get("pockets", [])
outer_2d = profile.get("outer_boundary", [])
@@ -852,15 +856,19 @@ def main():
and 'lines' in pockets[0])
if is_structured:
lister.WriteLine(f"[import] Structured format: {len(pockets)} pockets + outer boundary")
lister.WriteLine(f"[import] Structured format: {len(pockets)} pockets"
+ (" + outer boundary" if DRAW_OUTER_BOUNDARY else " (no outer boundary)"))
# Outer boundary
outer_lines, outer_arcs = _draw_outer_boundary(work_part, outer_2d, transform, lister)
lister.WriteLine(f"[import] Outer boundary: {outer_lines} lines + {outer_arcs} arcs")
# Pocket outlines (the red lines: 3 lines + 3 arcs each)
total_lines = outer_lines
total_arcs = outer_arcs
# Outer boundary (only when creating standalone plate, not subtract workflow)
total_lines = 0
total_arcs = 0
if DRAW_OUTER_BOUNDARY:
outer_lines, outer_arcs = _draw_outer_boundary(work_part, outer_2d, transform, lister)
total_lines = outer_lines
total_arcs = outer_arcs
lister.WriteLine(f"[import] Outer boundary: {outer_lines} lines + {outer_arcs} arcs")
else:
lister.WriteLine(f"[import] Outer boundary skipped (DRAW_OUTER_BOUNDARY=False)")
for idx, pocket in enumerate(pockets):
nl, na = _draw_structured_pocket(work_part, pocket, transform, lister)
total_lines += nl
@@ -899,8 +907,10 @@ def main():
else:
# Legacy format: pockets are point lists
lister.WriteLine(f"[import] Legacy format: {len(pockets)} pocket polylines")
outer_lines, outer_arcs = _draw_outer_boundary(work_part, outer_2d, transform, lister)
total_lines = outer_lines
total_lines = 0
if DRAW_OUTER_BOUNDARY:
outer_lines, _ = _draw_outer_boundary(work_part, outer_2d, transform, lister)
total_lines = outer_lines
for pocket_pts in pockets:
if len(pocket_pts) < 3:
continue