Hi everyone,
I was trying to get a floor outline contour, assuming it worked just like a wall (or other line driven elements) location curve.
However, the locations I extract with Python are neither curves nor points. When applied to floors, the Element.GetLocation node gives an error as well.
So, does anyone have an idea how to get a floor contour with the API?
It’s a bit tricky but it’s doable with a workaround.
If you use doc.Delete() on the floor you get the list of deleted elements as return. There you will find all the lines that make the floor sketch. Roll back the transaction to un-delete the floor.
In the springs package there is a node called “Springs.Collector.ElementSketch”. This will return the lines that form the floor. Might be a bit easier to use that instead.
@mikael_deity
Thanks for you code in advance, but I encounter a problem that expect ElementId ,got int
Actually, I know the object type of ElementId is int, but is it the wrong input which the function need??
I have changed approach for this problem and use the top host faces perimeters that can be extracted with the API
code below:
# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import RevitNodes
clr.AddReference("RevitNodes")
import Revit
# Import Revit elements
from Revit.Elements import *
# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import System
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below this line
floor = UnwrapElement(IN[0])
references = HostObjectUtils.GetTopFaces(floor)
faces = []
for reference in references:
faces.extend(floor.GetGeometryObjectFromReference(reference).ToProtoType())
curves = []
for face in faces:
curves.append(face.PerimeterCurves())
# Assign your output to the OUT variable.
OUT = curves