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: 

Retrieving file name using python

1 REPLY 1
Reply
Message 1 of 2
jcstewa3
602 Views, 1 Reply

Retrieving file name using python

Does anyone know of a way to retrieve the file name for the active part in Fusion? And if possible, would I be able to move the file to a different folder on my computer using code?

1 REPLY 1
Message 2 of 2
PinRudolf
in reply to: jcstewa3

I think what you might be looking for can be found at the document object; document.name. Note that the name returns including the version of the document. You could remove that by splitting on the last space that was used in the string. (Assuming python, see .rsplit())

 

You could also look into document.datafile.name but for some reason my code does not execute when using that. (Should probably be reported) I'm not sure what the result would normally be, might very well not be equal to the document name at all! I say that because I've noticed that you can save multiple files with the same name. But this might not be what you are looking for anyway. (You could also look into document.datafile.copy() to make a copy to a different folder in a360)

 

 

app = adsk.core.Application.get()

# Document name docNameWithVersion = app.activeDocument.name docName = docNameWithVersion.rsplit(' ',1)[0]

# Data-file name __ Does not work
# app.activeDocument.dataFile.name

For export to your local drive you might want to look at design.exportManager. There is some example code here.

 

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