Object.Properties

Hello, is there a way to get Content information from Text objects using Dynamo in Civil 3D?
Converting Text to MText is not an option for me, unfortunately.

Tnx

I have found a workaround, but since I’ve got used to Dynamo in Revit, i still use the same logic as I’ve done there and in Civil it doesn’t always work. Is there a node similar to Element.GetParameterByName in Civil 3D? To get any information from Properties window for an object?

Tnx!!

Hi @BIM_Croatia

Well! You can get the Text Objects Contents without converting MText:

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.
	
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
	with adoc.Database as db:
		with db.TransactionManager.StartTransaction() as t:
			bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
			btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
			tv = []
			errorReport = None
			for oid in btr:
				bl = t.GetObject(oid, OpenMode.ForRead)
				try:
					if isinstance(bl, DBText):
						tv.append(bl.TextString)
						
				# Catch and report Exception...	
				except:
					import traceback
					errorReport = traceback.format_exc()
					
			t.Commit()
           				

# Assign your output to the OUT variable.

if errorReport == None:
	OUT = tv#Text Values
else:
	OUT = errorReport
2 Likes

Thank you very much!!!

Works like charm!!

in this case I would set OpenMode to .ForRead for btr , thanks for sharing your code

You’re Welcome!