Different undo behaviors between API and UI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Run the script to create two sketch lines, the undoes are list in sub levels. Do the same operations on UI, the undoes are all list in first level. Why the api undoes are grouped but not the UI's?
import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) design = app.activeProduct # Get the root component of the active design. rootComp = design.rootComponent # Create a new sketch on the xy plane. sketches = rootComp.sketches; xyPlane = rootComp.xYConstructionPlane sketch = sketches.add(xyPlane) # Draw two connected lines. lines = sketch.sketchCurves.sketchLines; line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(3, 1, 0)) line2 = lines.addByTwoPoints(line1.endSketchPoint, adsk.core.Point3D.create(1, 4, 0)) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
.