Autocad Solid Material

Hi,

In dynamo for Civil3d is that possible to acces the material propreties of an object (autocad solid)? I’m able to get the object color and layer but not the material.

thanks for your help

Hi @francois.picard

I haven’t find any nodes to get material but you can get with python:

import sys
import clr
import math
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')
clr.AddReference('Civil3DNodes')
from Autodesk.Civil.DynamoNodes import Profile
# 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.
from Autodesk.DesignScript.Geometry import Point, Polygon	
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)
			mt = []
			
			errorReport = None
			for oid in btr:
				bl = t.GetObject(oid, OpenMode.ForRead)
				try:
					if isinstance(bl, Solid3d):
						mt.append(bl.Material)
				# Catch and report Exception...	
				except:
					import traceback
					errorReport = traceback.format_exc()
					
			t.Commit()
           				

# Assign your output to the OUT variable.

if errorReport == None:
	OUT = mt#Material
else:
	OUT = errorReport
4 Likes

I’m adding it to the Civil 3D Toolkit in the next release

4 Likes

Thanks @Kulkul!!

And good idea @Paolo_Emilio_Serra1