Is there a way to get surfaces volumes from Dynamo?

With a Great help from Paolo I Manage to create this Python Scrypt to get the surface volume:

#Get net Volume from volume surface

__author__ = 'Jesus A Duran - jduran@moffattnichol.com'
__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 *

# 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):
	global adoc
	
	vsid = None
	
	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)
				
				for oid in btr:
					obj = t.GetObject(oid, OpenMode.ForRead)
					if isinstance(obj, TinVolumeSurface):
						if obj.Name == vs_name:
							vsid = oid
					if vsid is not None:
						break
				
				if vsid is None:
					return "Surface not found"

				vs = t.GetObject(vsid, OpenMode.ForRead)
				props = vs.GetVolumeProperties()
				
				for a in dir(props):
					try:
						output[a] = getattr(props, a)
					except:
						pass
				t.Commit()
	return output["UnadjustedNetVolume"]/27 #Converting to Cu. Yards

OUT = get_tinvolumesurface_Vol(IN[0])

Find the attached Dynamo file, you’ll have to change the “VOL-PG-FILL” for the name of the volume surface you want to get data from.

If you don’t have the volume surface created and you want dynamo to do it, check this Paolo script:
https://forum.dynamobim.com/t/getting-surface-information-from-c3d-using-python/44258/6?u=jduran

Get_Surface Vol.dyn (5.9 KB)

1 Like