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:
|
if all_lines:
|
||||||
try:
|
try:
|
||||||
# Sketch.AddGeometry(infer, ellipse, curves)
|
# Sketch.AddGeometry(infer, ellipse, curves)
|
||||||
sketch.AddGeometry(
|
# Enums are nested under NXOpen.Sketch, not NXOpen directly
|
||||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
infer = NXOpen.Sketch.InferConstraintsOption.InferNoConstraints
|
||||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
ellipse = NXOpen.Sketch.AddEllipseOption.TreatAsEllipse
|
||||||
all_lines,
|
sketch.AddGeometry(infer, ellipse, 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")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
lister.WriteLine(f"[import] AddGeometry batch failed: {exc}")
|
lister.WriteLine(f"[import] AddGeometry batch failed: {exc}")
|
||||||
# Try adding one by one
|
# Try adding one by one
|
||||||
added = 0
|
added = 0
|
||||||
for line in all_lines:
|
try:
|
||||||
try:
|
infer = NXOpen.Sketch.InferConstraintsOption.InferNoConstraints
|
||||||
sketch.AddGeometry(
|
ellipse = NXOpen.Sketch.AddEllipseOption.TreatAsEllipse
|
||||||
NXOpen.InferConstraintsOption.InferNoConstraints,
|
except Exception:
|
||||||
NXOpen.AddEllipseOption.TreatAsEllipse,
|
infer = None
|
||||||
[line],
|
if infer is not None:
|
||||||
)
|
for line in all_lines:
|
||||||
added += 1
|
try:
|
||||||
except Exception:
|
sketch.AddGeometry(infer, ellipse, [line])
|
||||||
pass
|
added += 1
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
lister.WriteLine(f"[import] Added {added}/{len(all_lines)} lines individually")
|
lister.WriteLine(f"[import] Added {added}/{len(all_lines)} lines individually")
|
||||||
|
|
||||||
return total_lines
|
return total_lines
|
||||||
|
|||||||
Reference in New Issue
Block a user