Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Monitoring file upload often gets stuck

0 REPLIES 0
Reply
Message 1 of 1
KarolisCAMax
38 Views, 0 Replies

Monitoring file upload often gets stuck

I am uploading files by using api methods, such as saveCopyAs, etc..

I want to open these files when they are uploaded, but very often the API gets stuck and I am not any outcome from the DataFileFuture object.

Is there any better way to do that? Or maybe there are some workarounds? It's very time consuming because each time I must reboot Fusion app..

source: adsk.fusion.Component = occ.component

# Save a copy of the component to a new file
future: adsk.core.DataFileFuture = source.saveCopyAs(
  source.partNumber, parent_folder, "", ""
)
monitor_upload(future, source.name)
new_doc = app.documents.open(future.dataFile)
adsk.doEvents()

def monitor_upload(future :adsk.core.DataFileFuture, part_code):
    uploading = True
    while uploading:
        if future.uploadState == adsk.core.UploadStates.UploadFinished:
            uploading = False
            app.log('Uploaded: ' + part_code)
        elif future.uploadState == adsk.core.UploadStates.UploadFailed:
            ui.messageBox('The upload failed.')
            uploading = False
        adsk.doEvents()
0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report