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

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

CasettaMichael
Advocate Advocate
1,385 Views
6 Replies
Message 1 of 7

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

CasettaMichael
Advocate
Advocate

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

0 Likes
1,386 Views
6 Replies
Replies (6)
Message 2 of 7

JesusFreke
Advocate
Advocate

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?

0 Likes
Message 3 of 7

CasettaMichael
Advocate
Advocate

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

0 Likes
Message 4 of 7

JesusFreke
Advocate
Advocate

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 🙂

0 Likes
Message 5 of 7

kandennti
Mentor
Mentor

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

 

0 Likes
Message 6 of 7

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

0 Likes
Message 7 of 7

kandennti
Mentor
Mentor

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

0 Likes