Is there a way to get surfaces volumes from Dynamo?

Hello, I’m trying to create a script that adjust the length of a corridor based on a target volume.
First I was trying to get the volume from a TIN surface, but I had no luck getting that.
Then I thought of creating a solid from the surfaces (existing and proposed) but there is not a “Extract solid from surface” node.
Thanks,

Hi,
you can get solids and volume of the corridor like that:

1 Like

@jduran you could create the solids between surfaces in Dynamo and then extract the volume.
You have to create a watertight solid using the surfaces from the TIN and creating the necessary lateral faces to connect them.
It’s not always straight forward as the surfaces may intersect in multiple places but it can be done.

Hi,
Could it possible to write a node that provides volumes using API (API?

thanks

1 Like

Thanks for your reply, but I’m getting a “empty list” error

@jduran did you extract the solids from the corridor in Civil 3D before running Dynamo?

I didn’t, That’s the issue :slight_smile:

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