How to get the elevation from a ReferencePoint

Hello all,

For a project I am dealing with adaptive components in my models. I need to get the elevation of the adaptive points in the family. I made a script that collects the points and when you output them you can see that it is a ReferencePoint object with a location XYZ.
image

However I don’t seem to be able to grab the Z component from this. Point.Z gives me the error ‘AttributeError: ‘ReferencePoint’ object has no attribute ‘Z’’.
image
Inputting the point into the node ReferencePoint.Z does work, but this is not what I want because I want to contain everything in one script. Does anybody know what could be going on here? Am I missing a reference somewhere?

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

adap_points = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_AdaptivePoints).WhereElementIsNotElementType().ToElements()

z_coord = [point.Z for point in adap_points]


OUT = z_coord

Hi @johanboo,

Try with :

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
from Revit.Elements import *

z_coord = [point.Location.ToPoint().Z for point in adap_points]

Or z_coord = [point.Position.ToPoint().Z for point in adap_points]

The properties in the API :

1 Like

Thank you @Alban_de_Chasteigner

Adding the reference to GeometryConversion and using z_coord = [point.Position.ToPoint().Z for point in adap_points] did the trick! Apparently I was dealing with Revit points and I needed to convert them to Dynamo geometry first to be able to extract the elevation.

More explanation here: https://dynamopythonprimer.gitbook.io/dynamo-python-primer/4-revit-specific-topics/3.5-geometry-conversion-methods