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

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

Anonymous
Not applicable
1,002 Views
4 Replies
Message 1 of 5

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

Anonymous
Not applicable

Hi

 

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!

 

0 Likes
Accepted solutions (2)
1,003 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

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()
0 Likes
Message 3 of 5

BrianEkins
Mentor
Mentor
Accepted solution

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
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 4 of 5

Anonymous
Not applicable

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 🙂

0 Likes
Message 5 of 5

robertASTUP
Contributor
Contributor

Just adding a comment here that, nearly 5 years later I am still running in to many cases where a method to do this rather than use the workaround would be extremely useful. Would be really nice if this could be added to the API

0 Likes