# How do I code the Document.Current node into Python?

**URL:** <https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613>\
**Category:** Uncategorized\
**Created:** [June 13, 2022, 9:36pm UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613 "2022-06-13T21:36:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssimpsonHU35B](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@ssimpsonHU35B](https://forum.dynamobim.com/u/ssimpsonHU35B)\
**Post date:** [June 13, 2022, 9:36pm UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613/1 "2022-06-13T21:36:08Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/a/8a388af4c93c16f9c3ab16b135bb897b7eb8208d.png)

How Do I code the Document.Current node into python? Is there a way I can request the document be pulled from a specific filepath?

I’m looking for a way to call the Document node after dynamo opens the specific file automatically.

---

<div class="post-metadata">

**Author:** ![\_Vijay](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/_vijay/32/91307_2.png) [@\_Vijay](https://forum.dynamobim.com/u/_Vijay)\
**Post date:** [June 14, 2022, 3:02am UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613/2 "2022-06-14T03:02:56Z")

</div>

Is it in Civil 3D?

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 14, 2022, 4:35am UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613/3 "2022-06-14T04:35:34Z")

</div>

Does this help?

```auto
import System
from System import *

input = IN[0]

app = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application")
adoc = app.ActiveDocument

OUT = adoc, adoc.Name

```

Have a look into the LinkDWG package as well. 😉

Also, this topic is great for working with multiple DWG files.

> [@Run Dynamo Script on entire folder of dwg's](https://forum.dynamobim.com/t/run-dynamo-script-on-entire-folder-of-dwgs/53723/17):
>
> Here is the final Dynamo file with the references used. It could have been done in a different way, the main goal was to show how it is possible to run a script on multiple documents. [Run Function on multiple files.dyn](https://forum.dynamobim.com/uploads/short-url/cGDRZyKDeZ0uhDGRgz1qspMR11g.dyn) (21.2 KB)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 14, 2022, 5:21am UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613/4 "2022-06-14T05:21:26Z")

</div>

> [@ssimpsonHU35B](#):
>
> Is there a way I can request the document be pulled from a specific filepath?

No, this is not possible with the way Dynamo is implemented in Civil 3D. At least not with the Autodesk.AutoCAD.DynamoNodes.Document class.

> [@ssimpsonHU35B](#):
>
> I’m looking for a way to call the Document node after dynamo opens the specific file automatically.

What exactly are you looking to do here? When you first open Dynamo, it will be bound to the particular document that you opened it from. Switching to another document (either through your code or by clicking on another tab in the UI) will not result in Dynamo switching its context. This doesn’t mean that you can’t open up other drawings and work on them, it just means that you have to do so “outside” of Dynamo. In other words, you can’t use any of the Dynamo wrapper classes like the Document.Current node if you’re going to be working on a document other than the one that Dynamo launched from.

> [@ssimpsonHU35B](#):
>
> How Do I code the Document.Current node into python?

To directly answer your question, this is all you need…

```auto
from Autodesk.AutoCAD.DynamoNodes import *

OUT = Document.Current

```

…but at that point, it isn’t really accomplishing anything different from just using the node 😉

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 14, 2022, 5:29am UTC](https://forum.dynamobim.com/t/how-do-i-code-the-document-current-node-into-python/77613/5 "2022-06-14T05:29:11Z")

</div>

Also, take a look at the “External” shelf in the Camber package. There’s a lot in there to enable working with drawings other than the current one.

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