Retrieving file name using python

Retrieving file name using python

Anonymous
905 Views
1 Reply
Message 1 of 2

Retrieving file name using python

Anonymous
Not applicable

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?

0 Likes
906 Views
1 Reply
Reply (1)
Message 2 of 2

PinRudolf
Advocate
Advocate

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.