Is there a way to attach an image/pdf to a layout with Dynamo?

I’m trying to automate detail sheet creation using Dynamo. Typically, we create detail sheets by creating a layout and attaching the pdf as an xref. Is there a way to attach an image/pdf to a layout with Dynamo?

I don’t know if this helps or if this is working with image/pdf, but I created it for attaching dwg xref on multiple layouts. Pardon me for the script being a bit messy, I didn’t have time to polish. Look for the python script. I’m not sure but this may be achievable with packages since then. (Arkance, Camber, C3D Toolkit)
pecsét.dyn (138.9 KB)
)

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# 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 references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

def add_xref(path,blockName,switch,x,y,n):
	
	global adoc
	
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				# Determine whether to overlay or attach
				if switch==True:
					oid = db.OverlayXref(path, blockName)
				else:
					oid = db.AttachXref(path, blockName)
				if not oid.IsNull:
					for i in range (0,n):
						insPt = Point3d(x[i], -5, 0)					
						# Create block reference
						blkRef = BlockReference(insPt,oid)
						# Add block table record
						bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
						btr = t.GetObject(bt[y[i]], OpenMode.ForWrite)
						btr.AppendEntity(blkRef);
						t.AddNewlyCreatedDBObject(blkRef, True)		
					t.Commit()			
	
		return x
	
OUT = add_xref(IN[0],IN[1],IN[2],IN[3],IN[4],IN[5])


The Arkance Systems Node Library contains a node to add an Image Reference, also possible on a Layout.

4 Likes