import clr
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('ProtoGeometry')
# 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:
Surfaces.append(surface.Name)
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
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.
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?