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

1 Like

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
5 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!

Hi @Kulkul , Great.
I can use the text layer as input?

Yes you can use. Just change this and add layer name as input:

if isinstance(bl, DBText) and bl.Layer == IN[0]:

1 Like

Great, Thank you very much.

Hi @Kulkul. I am trying to extract the Pattern type so i can FilterbyBoolean and keep a specific pattern out of my list. Can the script be adjusted to find hatch patterns? If I could filter by Pattern type or Name that would be perfect.

Thank you!

@jpintocastaneda you can use the Civil 3D Toolkit:

2 Likes

FYI there are nodes for Text objects in Camber v3.0.0.

1 Like