Link to different DWG

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

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 @mzjensen how do you get the name of corresponding layout?

1 Like

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.

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.

Do some research on side databases. Good weekend reading :wink:

1 Like

Will do. Thanks Zachri!

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)

import clr
import os
import re

# Add Assemblies for AutoCAD APIs

# 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:
                for layoutName in layoutNames:

    if adoc:
        DocumentExtension.CloseAndSave(adoc, DWGPath)

OUT = allLayoutNames

GetLayoutNames.dyn (15.4 KB)

1 Like

There are nodes for this in Camber v4.1.0.