Getting surface information from C3D using Python


I’m trying to get surface information using a Python node,

I’m used to libraries information like this one that seems very different than this one

And I don’t manage to find any API reference guide for Autocad.

So far I manage to do this copying some code from @Paolo_Emilio_Serra1 and following this:

import clr

# Add Assemblies for AutoCAD and Civil 3D APIs

# Import references from AutoCAD

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
from Autodesk.Civil import FeatureLinePointType

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

doc = CivilApplication.ActiveDocument
Surfaces = []
for surfaceId  in doc.GetSurfaceIds:

OUT = Surfaces

But so far i have been just guessing without realizing which libraries should I import or assemblies to add and the results that I got is not a string,integer or any variable that I can use, all I get is IronPython.Runtime.Types.BuiltinFunction



the Assembly is what you add via clr.AddReference()
the Namespace is what you write at the import statement

They are already loaded in the Python template for your convenience.
If you want to know how a function works, call the name of function and use the _ _ doc_ _

property to get the Documentation String associated.
If you want to know which members are associated to an object call the dir() on the object.

here is a one line of code that looks at all the members of a Surface object


Thanks Paolo,
I finally did run the script without crashes or errors, felling like a total noob here

Changing the last line for:

OUT = [(m, getattr(VolumeSurfaceProperties, m).__doc__) for m in dir(VolumeSurfaceProperties)]

Manage to get the documentation of VolumeSurfaceProperties which have:
Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 10.5.768.0

Moving foward I’m trying to get the Fill volume using this line:

OUT = VolumeSurfaceProperties.UnadjustedFillVolume()

I get an error

IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 42, in
TypeError: getset_descriptor is not callable

I guess I need to specify the the surface I want to get the volume from, but I’m stuck there now.

not callable means that you are dealing with a property, not a method, basically you need to remove the parenthesis.

1 Like

Thanks Again Paolo, I get rid of the error, but the result I get is “IronPytho.Runtime.Types.ReflectedProperty” I was expecting a float/double value accordint to this:

Because you are calling the property on the class VolumeSurfaceProperties (the definition of the object) and not on an actual instance of that object.


Thanks Paolo! That Code is just what I need to understand how surfaces and others C3D object work with python.

I tink the params are commented backwards first surface will be base surface (bottom) second will be comparison (top) ¿rigth?

I do have another question regarding to the volumes units on the output. The drawing ambient setting are set on Cubic Yards, but the API output is on Cubic foot. Is this the default units output? Even if the drawing is set on metric?

Thanks again!

I am new to Dynamo, having only been working with it for a few days. So far, I’ve only focused on learning how to program in Python.
I would love to create a TinVolumeSurface, but I feel somewhat limited when creating nodes with Python. I believe there’s more potential with C#, but that territory is unknown to me. Could anyone guide me a bit? Any tutorials or courses you would recommend?
Thanks a lot!

C# is for efficiency, you can do anything that is in the .net library with python. C# will give you a faster results but it’s definitely a more complex language than python

Not quite. Stuff like interfaces and other data types don’t transfer completely, and Python is significantly less stable than C# in many of the areas in which it does transfer. This is doubly so in Civil 3D where the basic application has so many levels of abstraction and multiple things which require utilizing the IronPython2 package to even maintain base level functionality.

C# is vastly easier to build and maintain and more stable as a result.

The Python engine is slated for some review in the near future which should close some of the gap, but for now (to 2025.1 releases anyway) C# is far preferable for Civil3D interaction.