# Get the file name of the active revit document

**URL:** <https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865>\
**Category:** Revit\
**Created:** [August 28, 2016, 11:00am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865 "2016-08-28T11:00:00Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_246](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mark\_246](https://forum.dynamobim.com/u/Mark_246)\
**Post date:** [August 28, 2016, 11:00am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/1 "2016-08-28T11:00:00Z")

</div>

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.  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/3/3fc072a1a7b9c15b5d6bd9d7ccafe3083897de97.png)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [August 28, 2016, 11:24am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/2 "2016-08-28T11:24:22Z")

</div>

> [@Mark\_246](#):
>
> 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.

Hi Mark,

Here is one of the possible way using Python.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/0/0d72b2aa526bce998be1df2e2154887a73cae369.png)

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [August 28, 2016, 11:45am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/3 "2016-08-28T11:45:45Z")

</div>

@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 :

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/6/6fd4bba32ae456165c3f4ae850a6ac74a0b86a44.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [August 28, 2016, 11:59am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/4 "2016-08-28T11:59:44Z")

</div>

Nodes available OOTB …  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/8/830c2e95f3a7f5ff833e218653ccfb5737962d43.png)

---

<div class="post-metadata">

**Author:** ![Mark\_246](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mark\_246](https://forum.dynamobim.com/u/Mark_246)\
**Post date:** [August 29, 2016, 9:41am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/5 "2016-08-29T09:41:17Z")

</div>

Thanks for the assistance, all sorted now!

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [April 21, 2017, 11:09am UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/6 "2017-04-21T11:09:26Z")

</div>

2 posts were split to a new topic: [Extract name from File Path](https://forum.dynamobim.com/t/extract-name-from-file-path/11196)

---

<div class="post-metadata">

**Author:** ![c.barribaud](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@c.barribaud](https://forum.dynamobim.com/u/c.barribaud)\
**Post date:** [September 20, 2017, 12:03pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/7 "2017-09-20T12:03:20Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [September 20, 2017, 2:12pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/8 "2017-09-20T14:12:18Z")

</div>

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 :

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/d/fdb2e22a958505f6db5ff294406600e72c4828da.png)

```
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 :

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/f/2fd92b58a93a6e6dfa5ae506cc5f97adf2cbca82.png)

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [September 20, 2017, 2:28pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/9 "2017-09-20T14:28:41Z")

</div>

> [@Mostafa\_El\_Ayoubi](#):
>
> I’m not maintaining node-mode anymore

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

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [September 20, 2017, 3:29pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/10 "2017-09-20T15:29:28Z")

</div>

Absolutely! 🙂

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [September 20, 2017, 3:30pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/11 "2017-09-20T15:30:45Z")

</div>

Absolutely wonderful! 😀

---

<div class="post-metadata">

**Author:** ![Ron\_Allen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ron_allen/32/124849_2.png) [@Ron\_Allen](https://forum.dynamobim.com/u/Ron_Allen)\
**Post date:** [January 16, 2019, 7:58pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/12 "2019-01-16T19:58:11Z")

</div>

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]
```

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [February 5, 2019, 10:19pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/13 "2019-02-05T22:19:18Z")

</div>

The “Title” property of the Document can also be used ([additional documentation here](http://www.revitapidocs.com/2019/4cee7916-d799-fc83-daf3-97cb03900b72.htm)).

Note: The Document.Title property returns the title [without the extension](http://www.revitapidocs.com/2019/news?section=toc19) in the Revit 2019 API, although the above code would still work with the 2019 API.

---

<div class="post-metadata">

**Author:** ![Steve\_Fong1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Steve\_Fong1](https://forum.dynamobim.com/u/Steve_Fong1)\
**Post date:** [November 5, 2019, 5:54pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/14 "2019-11-05T17:54:07Z")

</div>

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

 ![CurrentDoc](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/a/7ae10f41f8da41aa919ff9c822cc58b08ca88b55.png)

What am I missing?

---

<div class="post-metadata">

**Author:** ![Steve\_Fong1](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Steve\_Fong1](https://forum.dynamobim.com/u/Steve_Fong1)\
**Post date:** [November 5, 2019, 6:07pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/15 "2019-11-05T18:07:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Remy\_Maurcot](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/remy_maurcot/32/21774_2.png) [@Remy\_Maurcot](https://forum.dynamobim.com/u/Remy_Maurcot)\
**Post date:** [September 16, 2022, 3:30pm UTC](https://forum.dynamobim.com/t/get-the-file-name-of-the-active-revit-document/5865/16 "2022-09-16T15:30:03Z")

</div>

It’s happen when your project file is not saved…
