Hello!
Can we observe projects list and project's directory/file structure?
Thank you!
Solved! Go to Solution.
Solved by sasikanth.kollipara. Go to Solution.
Solved by JeromeBriot. Go to Solution.
Hi, Thanks for using Fusion. Are you looking for API or a place to view the structure?
You can see it in the web interface as well.
If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!
Regards,
Sas
Hello,
Here is a script that list all hubs, projects, folders and files.
Note that the code takes time to end because it gets the information from the Autodesk server.
import adsk.core, adsk.fusion, traceback
import platform
import os
if platform.system() == 'Windows':
desktopPath = os.path.join(os.getenv('USERPROFILE'), 'Desktop')
else:
desktopPath = os.path.join(os.path.expanduser('~'), 'Desktop')
txtFile = os.path.join(desktopPath, 'DataFusion360.txt')
def getFolderData(folder, level, f):
for dataFile in folder.dataFiles:
f.write('\n' + '\t'*level + dataFile.name + ' | ' + dataFile.id)
for dataFolder in folder.dataFolders:
f.write('\n' + '\t'*level + dataFolder.name + ' | ' + dataFolder.id)
getFolderData(dataFolder, level+1, f)
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
with open(txtFile, 'w') as f:
for dataHub in app.data.dataHubs:
f.write(dataHub.name)
for dataProject in dataHub.dataProjects:
f.write('\n\t' + dataProject.name + ' | ' + dataProject.id)
getFolderData(dataProject.rootFolder, 2, f)
f.write('\n')
ui.messageBox('End')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file
Hello @sasikanth.kollipara! Thank you for replying!
https://www.autodesk.com/products/fusion-360/collaborator
shows me
is this because I have no some (what?) subscription?
And "ViewDetails on Web" brings me to a web observer for my projects
You can click Access now on the above screenshot you shared and you should be able to view the web interface.
And if you have the proper entitlement in Fusion, you are free to use this web interface for all your data management activities. You can do File operations pretty easy along with the review capabilities.
If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!
Regards,
Sas
Hi @JeromeBriot .
I have made a similar script, but I did not do such detailed information. It's great.
It seems to be slightly faster to use the asArray method.
However, empty folders, etc. caused an error.
Also, I am using it in a Japanese environment, and due to encoding problems, I get an error when writing the file. If you are not an English-speaking user, you may experience the same error.
So, I decode the file before writing it out.
# Fusion360API Python script
import adsk.core, adsk.fusion, traceback
import platform
import os
import time
if platform.system() == 'Windows':
desktopPath = os.path.join(os.getenv('USERPROFILE'), 'Desktop')
else:
desktopPath = os.path.join(os.path.expanduser('~'), 'Desktop')
txtFile = os.path.join(desktopPath, 'DataFusion360.txt')
def getFolderData(folder, level, lst):
try:
for dataFile in folder.dataFiles.asArray():
lst.append('\t'*level + dataFile.name + ' | ' + dataFile.id)
except:
pass
try:
for dataFolder in folder.dataFolders.asArray():
lst.append('\t'*level + dataFolder.name + ' | ' + dataFolder.id)
lst = getFolderData(dataFolder, level+1, lst)
except:
pass
return lst
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
t = time.time()
# get data
lst =[]
for dataHub in app.data.dataHubs.asArray():
lst.append(dataHub.name)
try:
for dataProject in dataHub.dataProjects.asArray():
lst.append('\t' + dataProject.name + ' | ' + dataProject.id)
lst = getFolderData(dataProject.rootFolder, 2, lst)
except:
pass
# write file
with open(txtFile, 'w') as f:
f.write(toDecode('\n'.join(lst)))
ui.messageBox(f'Done:{time.time()-t}s')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def toDecode(s):
return s.encode("CP932", "ignore").decode("CP932")
It is now faster than before, but access to the data hub is still slow.
@kandennti a écrit :
Also, I am using it in a Japanese environment, and due to encoding problems, I get an error when writing the file. If you are not an English-speaking user, you may experience the same error.
So, I decode the file before writing it out.
You can also try this :
with open(txtFile, 'w', encoding='cp932') as f:
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file
Can't find what you're looking for? Ask the community or share your knowledge.