Different undo behaviors between API and UI

mycad2016D8W4P
Enthusiast

Different undo behaviors between API and UI

mycad2016D8W4P
Enthusiast
Enthusiast

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

.

0 Likes
Reply
489 Views
1 Reply
Reply (1)

marshaltu
Autodesk
Autodesk

Hello,

 

That was known issue. API has different transaction logic from UI so that the items with same "names" in undo list will be grouped if they are next to each other. And the names for the same operation(e.g. draw rectangle with two points) in API and UI are different. But the undo behaviors for both API and UI should be same.

 

As you may be also aware, the undo list generated by API will not be localized. 

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes