API: sketch.move() throws RuntimeError on downstream feature errors, but native Move/Copy tool completes operation

API: sketch.move() throws RuntimeError on downstream feature errors, but native Move/Copy tool completes operation

mahmoud_parsipour_fr
Community Visitor Community Visitor
144 Views
0 Replies
Message 1 of 1

API: sketch.move() throws RuntimeError on downstream feature errors, but native Move/Copy tool completes operation

mahmoud_parsipour_fr
Community Visitor
Community Visitor

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())

 

  1. Create a simple design:

    • Create a sketch with a rectangle
    • Extrude it
    • Add fillets to edges
  2. Run the script above

  3. Expected (like native tool): Sketch moves, errors shown in Feature Health panel

  4. 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.

0 Likes
145 Views
0 Replies
Replies (0)