fix(import): use Sketch.InferConstraintsOption enum (nested under NXOpen.Sketch, not NXOpen)
This commit is contained in:
@@ -314,26 +314,27 @@ def _draw_polylines_batch(
|
||||
if all_lines:
|
||||
try:
|
||||
# Sketch.AddGeometry(infer, ellipse, curves)
|
||||
sketch.AddGeometry(
|
||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||
all_lines,
|
||||
)
|
||||
# Enums are nested under NXOpen.Sketch, not NXOpen directly
|
||||
infer = NXOpen.Sketch.InferConstraintsOption.InferNoConstraints
|
||||
ellipse = NXOpen.Sketch.AddEllipseOption.TreatAsEllipse
|
||||
sketch.AddGeometry(infer, ellipse, all_lines)
|
||||
lister.WriteLine(f"[import] Added {len(all_lines)} lines to sketch via AddGeometry")
|
||||
except Exception as exc:
|
||||
lister.WriteLine(f"[import] AddGeometry batch failed: {exc}")
|
||||
# Try adding one by one
|
||||
added = 0
|
||||
for line in all_lines:
|
||||
try:
|
||||
sketch.AddGeometry(
|
||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
||||
[line],
|
||||
)
|
||||
added += 1
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
infer = NXOpen.Sketch.InferConstraintsOption.InferNoConstraints
|
||||
ellipse = NXOpen.Sketch.AddEllipseOption.TreatAsEllipse
|
||||
except Exception:
|
||||
infer = None
|
||||
if infer is not None:
|
||||
for line in all_lines:
|
||||
try:
|
||||
sketch.AddGeometry(infer, ellipse, [line])
|
||||
added += 1
|
||||
except Exception:
|
||||
pass
|
||||
lister.WriteLine(f"[import] Added {added}/{len(all_lines)} lines individually")
|
||||
|
||||
return total_lines
|
||||
|
||||
Reference in New Issue
Block a user