fix: correct enum names from MCP - InferNoConstraints, TreatAsEllipse, UpdateLevel.Model runtime resolve
This commit is contained in:
@@ -315,8 +315,8 @@ def _draw_polylines_batch(
|
||||
try:
|
||||
# Sketch.AddGeometry(infer, ellipse, curves)
|
||||
sketch.AddGeometry(
|
||||
NXOpen.Sketch.InferConstraintsOption.DoNotInferConstraints,
|
||||
NXOpen.Sketch.AddEllipseOption.None_,
|
||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||
all_lines,
|
||||
)
|
||||
lister.WriteLine(f"[import] Added {len(all_lines)} lines to sketch via AddGeometry")
|
||||
@@ -327,8 +327,8 @@ def _draw_polylines_batch(
|
||||
for line in all_lines:
|
||||
try:
|
||||
sketch.AddGeometry(
|
||||
NXOpen.Sketch.InferConstraintsOption.DoNotInferConstraints,
|
||||
NXOpen.Sketch.AddEllipseOption.None_,
|
||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||
[line],
|
||||
)
|
||||
added += 1
|
||||
@@ -534,10 +534,21 @@ def main():
|
||||
|
||||
# Deactivate sketch
|
||||
try:
|
||||
sketch.Deactivate(
|
||||
view_false,
|
||||
False, # UpdateLevel — False or Model
|
||||
)
|
||||
# Resolve UpdateLevel enum at runtime
|
||||
update_model = None
|
||||
for path in ["NXOpen.Sketch.UpdateLevel.Model", "NXOpen.UpdateLevel.Model"]:
|
||||
try:
|
||||
parts_p = path.split(".")
|
||||
obj = __import__(parts_p[0])
|
||||
for attr in parts_p[1:]:
|
||||
obj = getattr(obj, attr)
|
||||
update_model = obj
|
||||
break
|
||||
except (AttributeError, ImportError):
|
||||
continue
|
||||
if update_model is None:
|
||||
update_model = 1 # numeric fallback
|
||||
sketch.Deactivate(view_false, update_model)
|
||||
except Exception as exc:
|
||||
lister.WriteLine(f"[import] Warning deactivating: {exc}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user