# Link to different DWG

**URL:** <https://forum.dynamobim.com/t/link-to-different-dwg/78711>\
**Category:** Civil 3D\
**Created:** [July 15, 2022, 6:09pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711 "2022-07-15T18:09:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SMorykin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/smorykin/32/111267_2.png) [@SMorykin](https://forum.dynamobim.com/u/SMorykin)\
**Post date:** [July 15, 2022, 6:09pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/1 "2022-07-15T18:09:32Z")

</div>

I am trying to get layout names of several dwgs. I’m using LINKDWG package and I can get the layouts to show up, but only for the current dwg that I’m accessing. Can this be done???

This graph may look messy, but only because I’m trying a bunch of different things to see if I can get it to work.

I’m using 2023

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/8/f88eaff2a81299fe9b9882c7ddfdd895e4b69bde.jpeg)

---

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [July 15, 2022, 8:21pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/2 "2022-07-15T20:21:14Z")

</div>

You can use the camber package to get the paper space blocks in an external document. Use “External Document”-\>“External Blocks”-\>“Is Layout”-\>“FilterByBoolMask” the external blocks. This will give you the paper space blocks. But @zachri.jensen how do you get the name of corresponding layout?

---

<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:** [July 15, 2022, 8:22pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/3 "2022-07-15T20:22:11Z")

</div>

Hi @SMorykin,

So long as you’re working with things in external drawings, you might check out the Camber package under the “External” shelf. There’s some handy stuff in there. As far as layouts go, it’s been on my list to add that to the package for awhile. I can bump that up in the priority list and put something together for you.

---

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [July 15, 2022, 8:23pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/4 "2022-07-15T20:23:56Z")

</div>

Other alternative is use the layout manager in a python node. Although, if i were to write the code it would have to open each drawing to get the layout names. Not sure how else to do it.

---

<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:** [July 15, 2022, 10:50pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/5 "2022-07-15T22:50:29Z")

</div>

> [@WrightEngineering](#):
>
> it would have to open each drawing to get the layout names. Not sure how else to do it.

Do some research on side databases. Good weekend reading 😉

---

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [July 15, 2022, 10:52pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/6 "2022-07-15T22:52:27Z")

</div>

Will do. Thanks Zachri!

---

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [July 16, 2022, 5:44pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/7 "2022-07-16T17:44:49Z")

</div>

Still have to do research on side databases. Here is a solution for now @SMorykin. But it has to open the drawings for a moment to grab the layout names. (Has to be python2 not 3)

```auto
import clr
import os
import re

# Add Assemblies for AutoCAD APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

import Autodesk.AutoCAD.ApplicationServices.Application as acapp
import Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExtension

#------------------------

DWGPaths = IN[0]
allLayoutNames = []

#Real Code

for DWGPath in DWGPaths:
    adoc = DocumentCollectionExtension.Open(acapp.DocumentManager, DWGPath, False)

    with adoc.LockDocument():
        with adoc.Database as db:
            with db.TransactionManager.StartTransaction() as t:
                layoutNames = [] 
                layoutDict = t.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite)
                
                for layout in layoutDict:
                	if "Model" not in layout.Key:
                		layoutNames.append(layout.Key)
                		
                for layoutName in layoutNames:
                	allLayoutNames.append(layoutName)

                t.Commit()
                pass
                
    if adoc:
        DocumentExtension.CloseAndSave(adoc, DWGPath)

OUT = allLayoutNames

```

[GetLayoutNames.dyn](https://forum.dynamobim.com/uploads/short-url/upZRjfP3vLCra3OMqhWTFjEDMz0.dyn) (15.4 KB)

 ![GetLayoutNames_2022-07-16_10-45-32](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/9/19ef9a7ea1eb6d366acf5077a2952455cffe7e9d.png)

---

<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:** [July 19, 2022, 2:56pm UTC](https://forum.dynamobim.com/t/link-to-different-dwg/78711/9 "2022-07-19T14:56:26Z")

</div>

@SMorykin,  
There are nodes for this in Camber v4.1.0.

 ![external_layout](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/0/30aaeab0e99d5b65d16eebf0a8500c4b3a5b99cf.png)
