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: 

Is there a script to get a full list of my files

6 REPLIES 6
Reply
Message 1 of 7
CasettaMichael
562 Views, 6 Replies

Is there a script to get a full list of my files

i am looking for a way to get a full list of all my files for the production staff. Is there an easy way to get a list of all my files? -mike

6 REPLIES 6
Message 2 of 7
JesusFreke
in reply to: CasettaMichael

Please define "My files" 🙂

 

Are you talking about files on your local disk, or fusion's cloud thingy? Do these files all exist in a specific directory?

Message 3 of 7
CasettaMichael
in reply to: JesusFreke

i am wanting to give a copy to production of all my files stored in the cloud.

Message 4 of 7
JesusFreke
in reply to: CasettaMichael

You can look at the Data* objects in the Api. e.g. start at the top level DataHubs, and from there you can find a specific DataHub, specific DataProject in that hub, and all of the DataFiles associated with that project. I don't have any experience with this API myself, so maybe someone else can chime in with more details about how to use those APIs to achieve what you want to do. But maybe this will get you pointed in the right direction at least 🙂

Message 5 of 7
kandennti
in reply to: CasettaMichael

Hi CasettaMichael.

 

I have made this in the past. However it is very very slow.

#FusionAPI_python GetDataList Ver0.0.1
#Author-kantoku
#Description-サインインしているID内の全ファイル名の取得・・・遅い!

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        #エクスポートファイルパス
        path = Get_Filepath(ui)
        if path is None:
            return
        
        #ファイル名の取得
        filenames = ''
        project = adsk.core.DataProject.cast(None)
        for project in app.data.dataProjects:
            results = ''
            results = getFiles(project.rootFolder, results, 0)
            filenames += results
        
        if len(filenames) < 1:
            ui.messageBox('Data not found')
            return
        
        #ファイルに書き込み
        file = open(path, 'w') 
        file.write(filenames) 
        file.close()
                
        ui.messageBox('Done')
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def getFiles(folder, results, depth):
    try:
        results += '\n' + (' ' * (depth * 4)) + folder.name

        f = adsk.core.DataFolder.cast(folder)
        file = adsk.core.DataFile.cast(None)
        for file in f.dataFiles:
            results += '\n' + (' ' * ((depth+1) * 4)) + file.name
      
        for subFolder in f.dataFolders:
            results = getFiles(subFolder, results, depth+1)
        
        return results
    except:
        return False

#ファイルパス
def Get_Filepath(ui):
    dlg = ui.createFileDialog()
    dlg.title = 'File name export'
    dlg.isMultiSelectEnabled = False
    dlg.filter = 'text(*.txt)'
    if dlg.showSave() != adsk.core.DialogResults.DialogOK :
        return
    return dlg.filename

 

Message 6 of 7
CasettaMichael
in reply to: kandennti

Not sure what I should do with this… where do I input this

Message 7 of 7
kandennti
in reply to: CasettaMichael

The above code is a python script.
Create a new script, copy and paste the code and execute it.
However, it is very slow.

 

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9701BBA7-EC0E-4016-A9C8-964AA4838954

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