DataShapes Civil 3D Select AutoCad Object Data

Hi @GinoKoolman

You need to convert ComObject to Autodesk.AutoCAD.DynamoNodes.Object which can be done with few lines of python:

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('Civil3DNodes')
clr.AddReference('AutoCADNodes')


# 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 *
from Autodesk.AutoCAD.Geometry import *

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
#Import References from dynamo
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery

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


def Get_Civil_Object(COMObject):
	if not isinstance(COMObject,list):
		COMObject = [COMObject]	
	output,handle = [],[]
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				for c in COMObject:
					handle.append(str(c.Handle))
				t.Commit()
		for h in handle:
			output.append(SelectionByQuery.GetObjectByObjectHandle(h))
		return output


OUT = Get_Civil_Object(IN[0])

3 Likes