Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Related items aren't updated after sketch is changed. adsk.doEvents() problem?

Message 1 of 4
399 Views, 3 Replies

Related items aren't updated after sketch is changed. adsk.doEvents() problem?



New to the forum and fairly new to the Fusion 360 API here.


I am making an Add-In, and at the base of it I need an extrusion, which is made on an construction plane that is defined to be normal to a sketch line, to be updated.


After running the command, the sketch line changes just fine, but the construction plane, and of course also the extrusion, remain unchanged until I manually hit Ctrl+B, at which point everything is fine.


I saw mentioned the command: "adsk.doEvents()"

but no matter where I put it nothing seems to happen?


Thanks in advance!


Message 2 of 4
in reply to: ljkCRMAD

I found a workaround for this. But surely there's a better way?


If I roll back the timeline to the beginning and then again to the end, everything updates as expected...


timeline = design.timeline
returnValue = timeline.moveToBeginning()
returnValue = timeline.moveToEnd()
Message 3 of 4
in reply to: ljkCRMAD

doEvents won't have any effect on this.  The API runs in the UI thread of Fusion and calling doEvents pauses your program and allows any other pending messages to be processed.  But that won't have any effect on how Fusion computes the model.  What's happening is that Fusion isn't recognizing that the sketch changed and isn't aware that it needs to recompute the modified feature. I thought we had a method to do that but I'm not seeing it now and maybe I'm confusing it with Inventor.  The reason that Fusion isn't aware of the change is that it's happening out of context through the API. You can mimic the same behavior that happens interactively to get it to work.  It's a variation of the same workaround you already found.  When you edit a sketch interactively, Fusion 360 rolls back the timeline to that sketch and then when you finish it rolls it to where it was previously.  You can roll the timeline to just after the sketch and then roll it back to where it was.  Depending on the size of the model and where the sketch is withing the timeline that can be much more efficient than rolling it to the beginning.

Brian Ekins
Inventor and Fusion 360 API Expert
Message 4 of 4
in reply to: BrianEkins

Thanks Brian,


Yeah, I have seen that I can also roll back in steps if that becomes necessary.

It works fine, but it does seem like that there should be a method for that 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report