Based on the topic you mentioned in the first post I created the following:
`#Get net Volume from volume surface
__author__ = 'Stan Bouwens'
__version__ = '1.0.0'
# Load the Python Standard and DesignScript Libraries
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')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbMgdbrep')
# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
# 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 *
from Autodesk.AutoCAD.BoundaryRepresentation import *
# Import references for PropertySets
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices 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.
dataEnteringNode = IN
adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
def get_tinvolumesurface_Vol(vs_name, base_surf, top_surf, vs_style, boundaries):
global adoc
if not isinstance(base_surf, list):
base_surf = [base_surf]
if not isinstance(top_surf, list):
top_surf = [top_surf]
if not isinstance(vs_name, list):
vs_name = [vs_name]
base_surf_id = []
top_surf_id = []
vsid = []
vs = []
props = []
dict = {}
output = []
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)
#get surfaces based on surface handle
for oid in btr:
obj = t.GetObject(oid, OpenMode.ForRead)
if isinstance(obj, TinSurface):
for b_handle in base_surf:
if obj.Handle.ToString() == b_handle:
base_surf_id.append(oid)
for t_handle in top_surf:
if obj.Handle.ToString() == t_handle:
top_surf_id.append(oid)
if len(base_surf_id+top_surf_id) is len(base_surf+top_surf):
break
if len(base_surf_id) is 0 or len(top_surf_id) is 0:
return "Surface is not a TIN surface"
for a in list(zip(vs_name, base_surf_id , top_surf_id)):
vsid = (TinVolumeSurface.Create(a[0], a[1], a[2], vs_style))
vs.append(t.GetObject(vsid, OpenMode.ForWrite))
#create bounded volume surfaces and append properties in dictionary
for j, k in zip(vs, boundary_p3dcol_split):
j.Rebuild()
vs_props = j.GetVolumeProperties()
maintask = {'Cut': int(vs_props.AdjustedCutVolume), "Fill": int(vs_props.AdjustedFillVolume), "Net": int(vs_props.AdjustedNetVolume), "Task name":j.Name}
output.append(maintask)
#delete the volume surfaces to prevent mess in Civil3D toolspace
j.Erase()
t.Commit()
return output
OUT = get_tinvolumesurface_Vol(IN[0], IN[1], IN[2], IN[3], IN[4])
Not the most cleanest code but it is functional. It is however required to have some basic knowledge of python to start with this .