How to create a polycurve from irregularly shaped floors?


I’m having trouble creating polycurves out of these floors that have modified point levels compared to a regular one. Is there a way to get these boundaries as a closed curve?

Hi!

I am afraid that the element sketch might be always flat, regardless to modified elevations of it’s points (it is so in Revit).
You can try the code below. Rather than using sketch it extracts edges from top faces of the floor and tries to remove duplicates/internal edges. Seems to work. As a result you can get a 3D polycurve with elevated points.

import clr

#The inputs to this node will be stored as a list in the IN variables.
floors = UnwrapElement(IN[0])

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

output = []

for f in floors:
	curve_list = []
	top_face_refs = HostObjectUtils.GetTopFaces(f)
	top_faces = []
	temp_edges = []
	#get all edges
	for face_ref in top_face_refs:
		face = doc.GetElement(face_ref).GetGeometryObjectFromReference(face_ref)
		if not face is None:
			top_faces.append(face)
			edge_arrays = face.EdgeLoops
			for edges in edge_arrays:
				for e in edges:
					temp_edges.append(e)
	#remove internal edges
	for e in temp_edges:
		f0 = e.GetFace(0)
		f1 = e.GetFace(1)
		valid = False
		if f0 is None:
			valid = True
		else:
			if not f0 in top_faces:
				valid = True
		if f1 is None:
			valid = True
		else:
			if not f1 in top_faces:
				valid = True
		
		if valid:
			#edge_list.append(e)
			c = e.AsCurve()
			curve_list.append(c.ToProtoType())
			
	output.append(curve_list)
				


#Assign your output to the OUT variable.
OUT = output


it works perfectly. Thanks a lot! This is just what I needed.

1 Like