Fix importer: always create new sketch + generate sandbox 2 rib profile (11 pockets)
This commit is contained in:
@@ -82,44 +82,14 @@ def _find_or_create_sketch(
|
|||||||
lister: Any,
|
lister: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
Find existing sketch by name, or create a new one on the sandbox plane.
|
Always create a new sketch on the sandbox plane and name it.
|
||||||
If found, delete all existing geometry in it (for update).
|
NX will auto-number internally (e.g. SKETCH_008).
|
||||||
|
The sketch Name attribute is set to sketch_name for identification.
|
||||||
Returns the Sketch object.
|
Returns the Sketch object.
|
||||||
"""
|
"""
|
||||||
import NXOpen
|
import NXOpen
|
||||||
|
|
||||||
# Try to find existing sketch by name
|
# Always create new sketch — NX handles duplicate names fine
|
||||||
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
|
|
||||||
lister.WriteLine(f"[import] Creating new sketch: {sketch_name}")
|
lister.WriteLine(f"[import] Creating new sketch: {sketch_name}")
|
||||||
|
|
||||||
origin = transform["origin"]
|
origin = transform["origin"]
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user