To run all of the floor elements in Revit link file at once

Hello,
Have a nice day.
Could you please advise me on this issue? I would like to select all of the floor elements in the Revit file at once, but this script permits only one element for a running process. How to modified for this script and python code?
My Revit version is 2022,
Dynamo core 2.10.1.3976, and
Dynamo Revit 2.10.1.4002
Thank you very much.


7.Get Width and Length of Floor.dyn (54.9 KB)

@nyeinthuaung ,

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

import math
	
floors = UnwrapElement(IN[0])

angle = []

for f in floors:
	angle.append(math.degrees(f.SpanDirectionAngle))
	
OUT = angle

with the defintion was something wrong

Yes,
My python script is the same as your mentioned. But I cannot get the target goal.

@nyeinthuaung

can you make transpose at @L1 before bounding box?

1 Like

@nyeinthuaung ,

i have no error… i just get rid of the ifNodes!

1 Like

Hello,
Thank you so much for your help @Draxl_Andreas.
I tried your dynamo script, it works well in some Revit files. But on my project file, there is another warning issue “Warning: One or more geometries have failed to convert due to this error: trim_with_edge_loops requires all curves to touch surface”.


So, I got a python code for this issue. But I can’t solve my problem at all.

Python Code is here;
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 functon
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 Exception as ex:
if “trim_with_edge_loops” in str(ex):
# failed conversion DB.Solid to 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)
else:
raise Exception(ex)

OUT = ds_Solids


9.Get Width and Length of Floor,( for all floors), error solve.dyn (86.6 KB)

#Python Code is here;
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 functon
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 Exception as ex:
        if “trim_with_edge_loops” in str(ex):
# failed conversion DB.Solid to 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)
else:
    raise Exception(ex)

OUT = ds_Solids

@nyeinthuaung , just better to copy and edit

1 Like

@Draxl_Andreas
my dynamo code is the same as the above code. But unluckily, there are no results with the warning.

which warnings? @nyeinthuaung

Dear @Draxl_Andreas;
I mentioned above "Warning: One or more geometries have failed to convert due to this error: trim_with_edge_loops requires all curves to touch surface”., could you please check…
Thank you so much for your help…

Hi, @nyeinthuaung

try to start from here: Solid union errors - INCONS_FACE -- inconsistent face-body relationships and FACE_BOUNDARY -- wire being deleted crosses face boundary

Just try to sort out “bad” floors and look into their profiles. Maybe some loops, or double curves are the problem? Anyway, feel free to share that floors, we’ll help!

1 Like

Hello @Vladimir;
Have a nice day.
I convert the dimension unit from meter to feet in the project file that you mentioned in the above post to solve my problem. But another problem is I only have little knowledge of python coding and dynamo. In the above post, the coding is used for beam unit changes, my approach is for floors. So, I edited the coding beam for floor. And I cannot solve my problem also. Could you please check the dynamo script and coding for me? I very much appreciate any help.

image

(upload://yuVk6NgPTsZsiwBOaeugKdOTIE6.dyn) (100.9 KB)

Just set units to Feets in Revit and test your initial script. If it works - well find how to set units to feets and back after run to millimeters.

1 Like