Material Volume = 0

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

1 Like

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…

@newshunhk ,

empty :confused:

Project1.rvt (4.8 MB)

yes this stair :frowning:

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 :frowning:
and some special shape stairs I cannot get their geometry :frowning:

an example with Python

python code (work on both engine)

import clr
import sys
import System
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

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)
        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
    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]

@c.poupin ,


it works thank you so much :slight_smile: !