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: 

Delete model from cloud

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
marylou.forsyth
315 Views, 2 Replies

Delete model from cloud

Looking to delete a specific model from the cloud where it was saved from an API script in python.  I found a 2015 post that says unable to do this thru the API, hoping a resolution was made since then.  That is my first question please.  Thank you on that in advance!  

 

My second question please is there a repository of API script commands available ?  I spend so much time looking for solutions on the API and Scripts forum if there was some documentation that had a good amount of the commands, it would be a time saver!!  Please understand we do everything from the API script as we have automated our process as much as I've been able to make it, so its just API scripting commands, I hope that is clear. Thank you as well in advance for any advice on this.

 

PS.  I got the All_Commands_Line_Options from Makoto Tanaka (- you are awesome!  )

 

Now I will tell you why...  We have an API script that brings in a model, updates any parameters, generates g-code and updates the model view with the new parameters.  Our issue is that our models have more than one setup and when only one setup is updated via the API scripting commands (generate toolpaths and post), the UI interface appears to loose connectivity and leaves old lines on the model, which confuses our machine operators.  A refresh solution was put in place last year (swap between design workspace and CAM workspace), but in October 2022 with a Fusion 360 release we lost the refresh, meaning the code stopped removing the (old) unwanted lines.  (same code, same models, different end result after upgrade) Basically if the operator clicks the TOP setup 'hide all' and 'show all' the view refreshes and things look perfect, no unwanted lines.  I posted how to toggle the setup from the API but its just not possible.  Unable to locate any resolution to this refreshing, this week I got the script to export the model as a d3f file thinking I could re-import it and show that to the operator but upon the re-import not enough is available (no simulation).  So yesterday and today I worked and have been able to save the model to the cloud, delete the view, and then bring it back in again.  At least it looks right now, but I need to be able to delete this temporary copy I saved to the cloud otherwise it will fill it up and that's not good.  I just can't locate how to delete this temporary model copy I saved to the cloud.  Fusion Support does know about this refresh issue, we informed them last October and I have been attempting to find a solution since then.  Any suggestions greatly appreciated!!!!  I ask because I am a programmer not an AutoCAD/Fusion 360 end user, and perhaps someone from that world can assist me? Thank you!!

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: marylou.forsyth

Hi @marylou.forsyth .

 

Cloud data can be deleted with the DataFile.deleteMe method.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-19656728-077B-4D7B-B31A-89956A297F1F 

Of course, this is limited to data that can be deleted when executed in the GUI.

 

The following sample deletes the first data file in the active folder in the data panel.
Since it really deletes the data, please try executing it after creating a new folder and saving a new document.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui = core.UserInterface.cast(None)
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        actDir: core.DataFolder = app.data.activeFolder
        if actDir.dataFiles.count < 1:
            return

        targetData: core.DataFile = actDir.dataFiles[0]

        res = ui.messageBox(
            f'Delete "{targetData.name}.{targetData.fileExtension}" stored in the cloud.\n Are you sure?',
            'DataFile deletion',
            core.MessageBoxButtonTypes.OKCancelButtonType)

        if not res == core.DialogResults.DialogOK:
            return

        targetData.deleteMe()
        app.isOffLine = True
        app.isOffLine = False

        ui.messageBox('Done')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Message 3 of 3
marylou.forsyth
in reply to: kandennti

Kandennti, again you are awesome!  Thank you for your response and so quickly too.  You have helped me so much, thank you!!  I don't see a way to approve your response but I do!  

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