Get the file name of the active revit document

Hi,

I’m wondering if it is it possible to get the file name of the active Revit document automatically using dynamo without having to manually browse for it.

I currently use the FilePath.FileName node, connected to the file path browse node; but this method requires the user to manually browse for the file when opening different projects.

Thanks for any help in advance.

Hi Mark,

Here is one of the possible way using Python.

3 Likes

@Mark_246

there is a node in node mode usineg the same API method as the one mentionned in kulkul’s reply, it gives the document name and the file path :

1 Like

Nodes available OOTB …

9 Likes

Thanks for the assistance, all sorted now!

1 Like

2 posts were split to a new topic: Extract name from File Path

Hi,

I would find the node you show, where can I find it ?

hi @c.barribaud ,
I’m not maintaining node-mode anymore and I didn’t move this node to Data-Shapes. Here’s the code though if wou want it :

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
path = doc.PathName
docname = path.encode('string-escape')


OUT = docname.split('\\\')[-1] , path

you can also do it with ootb nodes :

1 Like

May I ask something: will you maintain the Data-Shapes package in the future? :slight_smile:

Absolutely! :slight_smile:

1 Like

Absolutely wonderful! :grinning:

1 Like

There was a formatting error in the text- this gets just the filename form the document path:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
path = doc.PathName

OUT = (path.split('/')[-1]).split('.')[0]
2 Likes

The “Title” property of the Document can also be used (additional documentation here).

Note: The Document.Title property returns the title without the extension in the Revit 2019 API, although the above code would still work with the 2019 API.

2 Likes

I am trying to retrieve the name of the current Revit Document. I have tried two nodes, and neither seem to work.

What am I missing?

I just saw that there is an update from 2.02 to 2.03. Installed it and it now works!