I am trying to get the volume of stairrun, but I got this:
I can’t use element.geometry on my stair coz it is a spiral stair
I am trying to get the volume of stairrun, but I got this:
I can’t use element.geometry on my stair coz it is a spiral stair
Hello,
can you share a simple rvt file with the spiral stair?
@newshunhk , hi
Have you tried also accessing runs and Landing? actually you can also access via Element.Solid…
yes the only way to get the volume of this stair is by element.geometry
but using too much geometry will sometimes makes my revit freeze up
and some special shape stairs I cannot get their geometry
an example with Python
python code (work on both engine)
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
sdkNumber = int(app.VersionNumber)
def convert_volume(value_volume):
if sdkNumber < 2022:
UIunit = doc.GetUnits().GetFormatOptions(UnitType.UT_Volume).DisplayUnits
unit_symbol = doc.GetUnits().GetFormatOptions(UnitType.UT_Volume).UnitSymbolType
label_symbol = LabelUtils.GetLabelFor(unit_symbol)
else:
UIunit = doc.GetUnits().GetFormatOptions(SpecTypeId.Volume).GetUnitTypeId()
unit_symbol = doc.GetUnits().GetFormatOptions(SpecTypeId.Volume).GetSymbolTypeId()
label_symbol = LabelUtils.GetLabelForSymbol(unit_symbol)
convert_value = UnitUtils.ConvertFromInternalUnits(value_volume, UIunit)
return "{0:.3f} {1}".format(convert_value, label_symbol)
def get_VolumeSolid(elem):
opt = Options()
vol_cfeet = 0
geoSet = elem.get_Geometry(opt)
for geo in geoSet:
if isinstance(geo, Solid):
vol_cfeet += geo.Volume
elif isinstance(geo, GeometryInstance):
geoi = geo.GetInstanceGeometry()
for g in geoi:
if isinstance(g, Solid):
vol_cfeet += g.Volume
geoSet.Dispose()
opt.Dispose()
return convert_volume(vol_cfeet)
def toList(x):
if isinstance(x, list):
return x
elif hasattr(x, "GetType") and x.GetType().GetInterface("IEnumerable") is not None:
return x
else :
return [x]
lstelems = toList(UnwrapElement(IN[0]))
OUT = [get_VolumeSolid(e) for e in lstelems]
it works thank you so much !