Vertices of solid through Dynamo Revit

Hello everyone,

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.


This is the result i am getting and also the result that i want.

Here is my script and a revit file with a similar Family.
2020-05-01 Solid naar rechthoek CSV.dyn (38.7 KB)
Test Project met voorbeeld framing.rvt (1.6 MB)

Thanks in advance!

  • Daan

Hello @Daan
a solution with Python

#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
2 Likes

Code updated, finaly I used face of Solid

1 Like

Thank you for your reply! I will definitely check this out soon!

I cant thank you enough for your time!

Hey c.poupin,

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.

Thanks in advance!

  • Daan

Hi @Daan
Have you an example with a rvt or a picture?
Note:
calculating a lot of distances of objets requires a lot of memory