Hi!
I got planar faces where I extracted from solid using solid.Faces
But how can I convert them to DS faces?
I tried GetSurface() but it returns plane
thanks!
Hi!
I got planar faces where I extracted from solid using solid.Faces
But how can I convert them to DS faces?
I tried GetSurface() but it returns plane
thanks!
Can you share the code? which Dynamo and Revit do you use?
Just trying to find all the surfaces of a stair:
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
def get_VolumeSolid(elem):
opt = Options()
solid = []
geoSet = elem.get_Geometry(opt)
for geo in geoSet:
if isinstance(geo, Solid):
for f in geo.Faces:
solid.append(f.ToProtoType())
elif isinstance(geo, GeometryInstance):
geoi = geo.GetInstanceGeometry()
for g in geoi:
if isinstance(g, Solid):
for f in g.Faces:
solid.append(f.ToProtoType())
geoSet.Dispose()
opt.Dispose()
return solid
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]
I don’t use element.geometry because it will halt my revit or fail to convert if there is some spiral or bad drawn sketch based stairs.
oh… hmmm
# This node has been made by Modelical
# www.modelical.com
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
def flatten(x):
result = []
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(flatten(el))
else:
result.append(el)
return result
def toList(input):
"""Return iterable if available, a list of 1 otherwise"""
if hasattr(input, "__iter__") and not isinstance(input, basestring):
return input
else:
return [input]
stairs = toList(IN[0])
stairsSrfs = []
stairAreas = []
for st in stairs:
solids = st.Geometry()
tempPSrf = []
for s in solids:
tempPSrf.append(PolySurface.Surfaces(PolySurface.BySolid(s)))
stairsSrfs.append(flatten(tempPSrf))
for sSrfs in stairsSrfs:
tempSrf = []
for srf in sSrfs:
if Surface.NormalAtParameter(srf, 0, 0).Z == 1:
tempSrf.append(srf.Area)
stairAreas.append(sum(map(float,tempSrf)))
OUT = stairAreas
Hi @newshunhk,
You have to import the RevitNodes.dll and use geometryconversion to use ToProtoType()
.
clr.AddReference('RevitNodes')
import Revit
# Adds ToProtoType, ToRevitType geometry conversion extension methods to objects
clr.ImportExtensions(Revit.GeometryConversion)
import clr
clr.AddReference('RevitNodes')
import Revit
# Adds ToProtoType, ToRevitType geometry conversion extension methods to objects
clr.ImportExtensions(Revit.GeometryConversion)
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
doc = DocumentManager.Instance.CurrentDBDocument
def get_VolumeSolid(elem):
opt = Options()
solid = []
geoSet = elem.get_Geometry(opt)
for geo in geoSet:
if isinstance(geo, Solid):
for f in geo.Faces:
solid.append(f.ToProtoType())
elif isinstance(geo, GeometryInstance):
geoi = geo.GetInstanceGeometry()
for g in geoi:
if isinstance(g, Solid):
for f in g.Faces:
solid.append(f.ToProtoType())
geoSet.Dispose()
opt.Dispose()
return solid
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]
oh!!! yes I forgot to import
thank you !!!