Fix importer: always create new sketch + generate sandbox 2 rib profile (11 pockets)

This commit is contained in:
2026-02-16 21:49:07 +00:00
parent c5226084fe
commit 1bfc747cf9
2 changed files with 1000 additions and 62 deletions

View File

@@ -82,44 +82,14 @@ def _find_or_create_sketch(
lister: Any,
) -> Any:
"""
Find existing sketch by name, or create a new one on the sandbox plane.
If found, delete all existing geometry in it (for update).
Always create a new sketch on the sandbox plane and name it.
NX will auto-number internally (e.g. SKETCH_008).
The sketch Name attribute is set to sketch_name for identification.
Returns the Sketch object.
"""
import NXOpen
# Try to find existing sketch by name
existing_sketch = None
try:
for feat in part.Features:
fname = ""
try:
fname = feat.Name
except Exception:
continue
if fname == sketch_name:
try:
existing_sketch = feat.GetEntities()[0]
lister.WriteLine(f"[import] Found existing sketch: {sketch_name}")
except Exception:
pass
break
except Exception:
pass
if existing_sketch is not None:
try:
existing_sketch.Activate(False)
all_geom = existing_sketch.GetAllGeometry()
if all_geom:
existing_sketch.DeleteObjects(list(all_geom))
lister.WriteLine(f"[import] Cleared {len(all_geom)} objects from existing sketch")
existing_sketch.Deactivate(False, False)
except Exception as exc:
lister.WriteLine(f"[import] Warning clearing sketch: {exc}")
return existing_sketch
# Create new sketch on the sandbox plane
# Always create new sketch — NX handles duplicate names fine
lister.WriteLine(f"[import] Creating new sketch: {sketch_name}")
origin = transform["origin"]

File diff suppressed because it is too large Load Diff