Spot Slope Values

great idea Cyril :wink: , think it could work :wink:


slope.dyn (6.7 KB)

You can calculate the slope of face geometry by using the FaceNormal and projecting onto the XY plane. You also now have the face geometry which could be used to intersect with other elements
EDIT: Z could be negative so testing for Z == 0 first instead of Z > 0

import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import HostObjectUtils, UV


def face_slopes(floor):
    result = []
    for face in HostObjectUtils.GetTopFaces(floor):
        normal = floor.GetGeometryObjectFromReference(face).FaceNormal
        if normal.Z == 0:  # Slope is 1, avoids div by zero
            result.append(1)
        else:
            # Map normal onto xy plane
            # No need to negate the normal as we are only using the length
            result.append(
                round(UV(normal.X / normal.Z, normal.Y / normal.Z).GetLength(), 4)
            )
    return result


output = []
floors = UnwrapElement(IN[0]) if isinstance(IN[0], list) else [UnwrapElement(IN[0])]

for floor in floors:
    output.append(face_slopes(floor))

OUT = output


Great one Mike very usefull, if user want all surface slopes and not only from dimension…