Hi,
here another workaround geometry conversion, using Solid.ByJoinedSurfaces() (only for solids with planar faces)
import clr
import System
import sys
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
def get_AllSolid(lst_elem, inc = 0):
# sub functon
def populate_lstGeo(g):
if isinstance(g, Solid) and g.Volume > 0:
solids.append(g)
elif isinstance(g, GeometryInstance):
geoInst.append(g)
else:pass
#
# main recursive function
global opt
solids = []
geoInst = []
lst_elem = lst_elem if hasattr(lst_elem, "__iter__") else [lst_elem]
if len(lst_elem) > 0 and inc < 2000:
for elem in lst_elem:
if isinstance(elem, GeometryInstance):
for j in elem.GetInstanceGeometry():
populate_lstGeo(j)
else:
geoSet = elem.get_Geometry(opt)
for i in geoSet:
populate_lstGeo(i)
return solids + get_AllSolid(geoInst, inc + 1)
else:
return []
elem = UnwrapElement(IN[0])
opt = Options()
solids = get_AllSolid(elem)
ds_Solids = []
for s in solids:
try:
ds_Solid = s.ToProtoType()
ds_Solids.append(ds_Solid)
except:
# failed conversion DB.Solid to Solid Prototype -> try get make Solid with ByJoinedSurfaces
ds_face = []
for f in s.Faces:
try:
ds_face.extend(f.ToProtoType())
except:
# failed conversion DB.Face to Prototype -> try get make Surface with PolyCurves.Patch()
ds_edges = [c.ToProtoType() for curveloop in f.GetEdgesAsCurveLoops() for c in curveloop]
ds_poly_edges = PolyCurve.ByJoinedCurves(ds_edges)
ds_face.append(ds_poly_edges.Patch())
ds_Solid = DS.Solid.ByJoinedSurfaces(ds_face)
ds_Solids.append(ds_Solid)
OUT = ds_Solids