API: sketch.move() throws RuntimeError on downstream feature errors, but native Move/Copy tool completes operation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm developing an Add-in that moves sketch entities. When using sketch.move() and the operation causes downstream features (like Extrude, Fillet) to fail, the API throws a RuntimeError and the entire operation is cancelled.
However, the native Move/Copy tool in Fusion behaves differently:
- The move operation completes successfully
- Downstream errors are shown in the Feature Health panel
- Failed features turn yellow/red in the Timeline
- User can decide to fix errors later or Undo
My question: Is there a way to make sketch.move() behave like the native tool - complete the operation and report errors through Feature Health instead of throwing an exception?
I've searched for options like suppressErrors, allowComputeErrors, or isComputeDeferred but couldn't find anything in the API.
Thank you!
import adsk.core
import adsk.fusion
import adsk.cam
import traceback
def run(context):
app = adsk.core.Application.get()
ui = app.userInterface
try:
design = adsk.fusion.Design.cast(app.activeProduct)
if not design:
ui.messageBox('No active design')
return
# Get first sketch (must have dependent features like Extrude)
if design.rootComponent.sketches.count == 0:
ui.messageBox('No sketches in design')
return
sketch = design.rootComponent.sketches.item(0)
# Collect all sketch entities
collection = adsk.core.ObjectCollection.create()
for curve in sketch.sketchCurves:
collection.add(curve)
for point in sketch.sketchPoints:
if not point.isFixed:
collection.add(point)
# Create transform (move 5cm in Z)
transform = adsk.core.Matrix3D.create()
transform.translation = adsk.core.Vector3D.create(0, 0, 5.0)
# This throws RuntimeError if downstream features fail
sketch.move(collection, transform)
ui.messageBox('Move completed successfully')
except RuntimeError as e:
# Operation is cancelled, nothing moved
ui.messageBox(f'RuntimeError - operation cancelled:\n\n{e}')
except:
ui.messageBox(traceback.format_exc())
Create a simple design:
- Create a sketch with a rectangle
- Extrude it
- Add fillets to edges
Run the script above
Expected (like native tool): Sketch moves, errors shown in Feature Health panel
Actual: RuntimeError thrown, sketch not moved at all
---------------------------
Error Show
---------------------------
RuntimeError - operation cancelled:
3 : Extrude1 / Compute Failed // NO_TARGET_BODY - No target body!
Fillet1 / 1 Reference Failures The edge reference is lost and this feature is using cached geometry. Edit this feature and select new edge references. // EDGE_REFERENCE_LOST - Edge 1 missing / Compute Failed // FILLET_NO_EDGE_FOUND - No fillet edge found.