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:
|
try:
|
||||||
# Sketch.AddGeometry(infer, ellipse, curves)
|
# Sketch.AddGeometry(infer, ellipse, curves)
|
||||||
sketch.AddGeometry(
|
sketch.AddGeometry(
|
||||||
NXOpen.Sketch.InferConstraintsOption.DoNotInferConstraints,
|
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||||
NXOpen.Sketch.AddEllipseOption.None_,
|
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||||
all_lines,
|
all_lines,
|
||||||
)
|
)
|
||||||
lister.WriteLine(f"[import] Added {len(all_lines)} lines to sketch via AddGeometry")
|
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:
|
for line in all_lines:
|
||||||
try:
|
try:
|
||||||
sketch.AddGeometry(
|
sketch.AddGeometry(
|
||||||
NXOpen.Sketch.InferConstraintsOption.DoNotInferConstraints,
|
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||||
NXOpen.Sketch.AddEllipseOption.None_,
|
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||||
[line],
|
[line],
|
||||||
)
|
)
|
||||||
added += 1
|
added += 1
|
||||||
@@ -534,10 +534,21 @@ def main():
|
|||||||
|
|
||||||
# Deactivate sketch
|
# Deactivate sketch
|
||||||
try:
|
try:
|
||||||
sketch.Deactivate(
|
# Resolve UpdateLevel enum at runtime
|
||||||
view_false,
|
update_model = None
|
||||||
False, # UpdateLevel — False or Model
|
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:
|
except Exception as exc:
|
||||||
lister.WriteLine(f"[import] Warning deactivating: {exc}")
|
lister.WriteLine(f"[import] Warning deactivating: {exc}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user