Working with imported geometries (CAD blocks) through python in Dynamo


I am trying to create a script using python to find the centroids of imported geometry in CAD blocks.


When the blocks are read by dynamo, it looks like they are UnknownInstances. How do I get Dynamo to ‘type’ them, so that I can use the API to sort the input array into a list of curves, and then run Curve.PointAtParameter to get the mid points. Averaging these would then allow me to get the centroid of the actual block itself, and that is the objective.

Could someone point me in the right direction please on how to work with UnknownInstances in order to accomplish this please?

The geometry referenced by the script. Each group of squiggles was imported as a block from a CAD file which was partially exploded.

There is a way to access Autocad data via

SEL= CAD.PickfirstSelectionSet
SEL = CAD.ModelSpace

if IN[0] == True and SEL != None and SEL.Count > 0:
	for obj in SEL:
		if obj.ObjectName == "AcDbPoint":
		if obj.ObjectName == "AcDbBlockReference":
			if AXX != None:
				for att in AXX:
		if obj.ObjectName == "AcDbText":
		if obj.ObjectName == "AcDbMText":
		if obj.ObjectName in ["AcDbSpline", "AcDbPolyline"]:
		if obj.ObjectName == "AcDbFace":


If the application is accessible this way, there must be a way to make the imported DWG and partially exploded blocks readable by Dynamo. Currently I am stumped since I cannot do anything with an UnknownElement type. It doesn’t have the ObjectName attribute.

1 Like