fix: add missing NXOpen.Features and NXOpen.GeometricUtilities imports
NXOpen submodules must be imported explicitly in NX's Python environment - they're not accessible as attributes of the parent module.
This commit is contained in:
@@ -98,20 +98,9 @@ def _find_old_sketch_feature(part: Any, sketch_name: str, lister: Any):
|
|||||||
def _replace_and_delete_old_sketch(part: Any, old_feature: Any, new_feature: Any, lister: Any):
|
def _replace_and_delete_old_sketch(part: Any, old_feature: Any, new_feature: Any, lister: Any):
|
||||||
"""
|
"""
|
||||||
Replace old sketch with new one using NX's ReplaceFeatureBuilder.
|
Replace old sketch with new one using NX's ReplaceFeatureBuilder.
|
||||||
|
|
||||||
This mirrors the interactive: right-click sketch → Replace Feature.
|
|
||||||
All downstream features (extrude, trim, etc.) automatically re-reference
|
|
||||||
the new sketch. The old sketch is deleted after replacement.
|
|
||||||
|
|
||||||
API: NXOpen.Features.ReplaceFeatureBuilder
|
|
||||||
- SelectFeature → original feature to replace
|
|
||||||
- ReplacementFeature → new feature that takes over
|
|
||||||
- DeleteOriginalFeature → True (remove old after remap)
|
|
||||||
- DoAutomaticGeomMatch → True (auto-match edges/curves)
|
|
||||||
- AutomatchMap() → run the auto-matching
|
|
||||||
- Commit() → execute the replacement
|
|
||||||
"""
|
"""
|
||||||
import NXOpen
|
import NXOpen
|
||||||
|
import NXOpen.Features
|
||||||
|
|
||||||
session = NXOpen.Session.GetSession()
|
session = NXOpen.Session.GetSession()
|
||||||
mark = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible,
|
mark = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible,
|
||||||
@@ -476,6 +465,8 @@ def _extrude_sketch(part: Any, sketch: Any, thickness: float,
|
|||||||
If an old extrude with the same name exists, delete it first.
|
If an old extrude with the same name exists, delete it first.
|
||||||
"""
|
"""
|
||||||
import NXOpen
|
import NXOpen
|
||||||
|
import NXOpen.Features
|
||||||
|
import NXOpen.GeometricUtilities
|
||||||
|
|
||||||
session = NXOpen.Session.GetSession()
|
session = NXOpen.Session.GetSession()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user