Nodes that require "document" input

There are many nodes that require a document input port, especially those used for selection. My understanding is that Dynamo can only work with the current active document. If that is the case, why are nodes built with a document input port? If the document input cannot be variable (it’s always the current document), why not just get the active document with the node code? Is this just a best practice just in case Dynamo can process multiple document in the future?

example:
image

2 Likes

In principle, yes. Dynamo points automatically to the active document.

You can also open documents in the background which would also allow you to access objects or information or perhaps to batch process files.

Interesting. I have not attempted this with Dynamo yet. Do you have a simple example?

I have a custom node that lets you input a linked a model.

The purpose of it is to automate the placement of pipe sleeves in architectural or structural walls.

I run it in my MEP model and it grabs the walls from the arch/structural model.

Does that make sense?

Another example is family editing. Whenever you do this your doing it on a “Document” other then the one Revit is running on, bit it’s being done in memory.

Frankly, I’d say half or better of all the graphs I make or use implement a document different than the main one.

Just a reminder - we’re talking about Civil 3D here, not Revit. Currently, I don’t believe that there is a way to work on anything other than the current DWG. But I would be pleased to know if this is possible.

3 Likes

Currently I have only need this work with the active document, however if you know how to create the document data type you should be able provide additional documents.

I strongly caution against that with the current element binding concerns on the C3D side.

1 Like

I’m sold. Did some testing and it was no problem pulling the coordinate system codes from other DWGs. Although, I haven’t figured out how to put the Dynamo wrapper on the documents so I can feed them into other nodes with a Document input.
Dyn-CSReport

Here’s the python if anyone is interested in expanding upon this.

import clr
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')

# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

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

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.Settings import *

filePath = IN[0]

code = []

for i in filePath:
	db = Database(False, True)
	db.ReadDwgFile(i, FileShare.ReadWrite, False, "")
	civDoc = CivilDocument.GetCivilDocument(db)
	settings  = civDoc.Settings.DrawingSettings

	try:
		code.append(settings.UnitZoneSettings.CoordinateSystemCode)
	except:
		code.append("")

	
	db.Dispose()

OUT = code
4 Likes

Awesome! So I figured out how to isolate .dwg files but like you I am finding it difficult to wrap it back around to add/modify those documents. Still testing and playing around to see what I can come up with.