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: 

Blocking Call to[As]

Message 1 of 2
138 Views, 1 Reply

Blocking Call to[As]


The API supports a callback that is called when a data file upload has completed including any cloud side translation, which is demonstrated by the Save and Insert File API Sample.


However, there are situations in my script where I just need to wait until the save is complete and can't continue until it is, e.g."new version")




Is there a way to do this with the API, for example by receiving a "future" object representing the result of the save, that can be waited on with future.result(timeout)? I note that the DataFolder and Component classes seems to support a DataFileFuture, but for some reason the[As] mechanism doesn't?


Will this functionality be coming to the API/or is there an example of how I can achieve what I am asking? I know it is less efficient, but in my use-case async programming just complicates my script which is essentially just automation of a human workflow.


Thank you!

Message 2 of 2
in reply to: scruffmeister

It's not ideal, but you can do something like the code below. The starts a loop where adsk.doEvents() is called. The API and the Fusion UI run in the same thread, so while the API is running, the Fusion UI is blocked. The doEvents function returns control over to Fusion so any pending messages can be processed and then control returns back to the API. The logic to end the loop in this is checking to see if a new version of this document is available. It would be wise to add something else, like a timeout, in case the save isn't able to complete and a new version never becomes available.



curVersion = doc.dataFile.latestVersionNumber"new version")
while doc.dataFile.latestVersionNumber == curVersion:




I agree that async programming is a pain, but comes into play anytime Fusion is interacting with its cloud side.

Brian Ekins
Inventor and Fusion 360 API Expert

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