Document rename

Document rename

p.seem
Advocate Advocate
612 Views
1 Reply
Message 1 of 2

Document rename

p.seem
Advocate
Advocate

Does anyone have a working example of renaming a document (I'm working on regular f3d documents, if it makes a difference) through the API?  

 

Both 'dataFile' and 'document' list name as a read/write field, but I'm not having any effect setting it.  Setting dataFile.name doesn't appear to do anything. Setting document.name changes the name as it appears in the browser/tree view, but that change is reset when I save the document (I don't just mean that the change isn't saved, but rather when you click save the name actually switches back in the browser/tree view).

 

For what it's worth, I've tried both renaming the data file when it was closed:

                    app = adsk.core.Application.get()
                    projs = app.data.dataProjects
                    testProj = [proj for proj in projs if proj.name == 'Test'][0]
                    dfs = testProj.rootFolder.dataFiles
                    mod1df = [df for df in dfs if df.name == 'mod1'][0]                   
                    mod1df.name = mod1df.name + '_REV'

and renaming the document and/or data file when it is open:

                    app = adsk.core.Application.get()
                    mydoc= app.documents.item(0)
                    mydoc.name = mydoc.name + '_REV'
                    mydoc.dataFile.name = mydoc.dataFile.name + '_REV'

Thanks for your suggestions.

 

Pete

0 Likes
Accepted solutions (1)
613 Views
1 Reply
Reply (1)
Message 2 of 2

p.seem
Advocate
Advocate
Accepted solution

For anyone who comes across this in the future:

 

It looks like this behavior has changed with the October 2016 update that was pushed out this morning.   Setting the dataFile.name field now has the expected effect.

0 Likes