I have made a small script to get the vertexes from a Revit Family through Dynamo.
But i am using a lot of nodes to do this and this is the first time for me.
I was wondering if there is a better/ more optimized way to get the same results.
#v2
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
def getBottomVertex(geo):
outVertices = []
filterEdges = []
if isinstance(geo, Solid):
minFaces = sorted(geo.Faces, key = lambda x : x.Area)[0:2]
for face in minFaces:
edgeArrArr = face.EdgeLoops
for edgeArr in edgeArrArr:
for edge in edgeArr:
edgeProto = edge.AsCurve().ToProtoType()
if edgeProto.StartPoint.Z == edgeProto.EndPoint.Z:
filterEdges.append(edgeProto)
elif round(edgeProto.Normal.Z) != 0:
filterEdges.append(edgeProto)
#filter with Z
filterEdges.sort(key = lambda x : (x.StartPoint.Z, x.EndPoint.Z ))
for edg in filterEdges[0:2]:
outVertices.extend([edg.StartPoint, edg.EndPoint])
return outVertices
elemlist = UnwrapElement(IN[0])
if not hasattr(elemlist, "__iter__"):
elemlist = [elemlist]
listVertices = []
op = Options()
for elem in elemlist:
geoms = elem.get_Geometry(op)
for geoinst in geoms:
if isinstance(geoinst, GeometryInstance):
geosymbs = geoinst.GetInstanceGeometry()
for geoelem in geosymbs:
bottomVertices = getBottomVertex(geoelem)
if bottomVertices:
#try with 'extend' if you want one list
listVertices.append(bottomVertices)
OUT = listVertices
First of all i would like to thank you very much for your Python script! (So don’t take this wrong)
But i am looking for a script that when multiple families are selected, the middle point from all these families combined will be used.
When i use your python script, i get a result for each stand alone family.
Also, is it possible to filter by distance? Like if 2 families are closer than 1 meter, they should be combined.