Skip to content

geom

Geometric utilities for Revit.

Attributes

Functions:

intersect_curves(curve1, curve2)

Intersects two curves on any engine and host API generation.

Hosts still shipping the Curve.Intersect(Curve, ref array) overload marshal the out-param engine-specifically (explicit clr.Reference under IronPython, direct tuple under CPython/pythonnet). Revit 2026+ removed that overload in favor of Curve.Intersect(Curve, CurveIntersectResultOption), detected here by TypeError fallback.

Parameters:

Name Type Description Default
curve1 Curve

first curve

required
curve2 Curve

second curve

required

Returns:

Type Description
tuple[SetComparisonResult, list[XYZ] | None]

comparison result, and the intersection points (None when the curves do not intersect).

Source code in pyrevitlib/pyrevit/revit/geom.py
def intersect_curves(curve1, curve2):
    """Intersects two curves on any engine and host API generation.

    Hosts still shipping the ``Curve.Intersect(Curve, ref array)`` overload
    marshal the out-param engine-specifically (explicit ``clr.Reference``
    under IronPython, direct tuple under CPython/pythonnet). Revit 2026+
    removed that overload in favor of ``Curve.Intersect(Curve,
    CurveIntersectResultOption)``, detected here by ``TypeError`` fallback.

    Args:
        curve1 (DB.Curve): first curve
        curve2 (DB.Curve): second curve

    Returns:
        (tuple[DB.SetComparisonResult, list[DB.XYZ] | None]):
            comparison result, and the intersection points (None when the
            curves do not intersect).
    """
    if IRONPY:
        results = clr.Reference[DB.IntersectionResultArray]()
        try:
            intres = curve1.Intersect(curve2, results)
            return intres, _extract_intersection_points(results.Value)
        except TypeError:
            pass
    else:
        try:
            intres, results = curve1.Intersect(curve2, None)
            return intres, _extract_intersection_points(results)
        except (TypeError, ValueError):
            pass
    intersect_result = curve1.Intersect(curve2, DB.CurveIntersectResultOption.Detailed)
    overlap_items = list(intersect_result.GetOverlaps() or [])
    points = [overlap.Point for overlap in overlap_items] if overlap_items else None
    return intersect_result.Result, points

convert_point_coord_system(rvt_point, rvt_transform)

Return coordinates of point in another coordinate system.

Parameters:

Name Type Description Default
rvt_point XYZ

Revit point

required
rvt_transform Transform

Revit transform for target coord system

required

Returns:

Type Description
XYZ

Point coordinates in new coordinate system.

Source code in pyrevitlib/pyrevit/revit/geom.py
def convert_point_coord_system(rvt_point, rvt_transform):
    """Return coordinates of point in another coordinate system.

    Args:
        rvt_point (DB.XYZ): Revit point
        rvt_transform (DB.Transform): Revit transform for target coord system

    Returns:
        (DB.XYZ): Point coordinates in new coordinate system.
    """
    # transform the origin of the old coordinate system in the new
    # coordinate system
    return rvt_transform.OfVector(rvt_transform.Origin - rvt_point)

convert_point_to_metric(rvt_point)

Convert given point coordinates to metric.

Source code in pyrevitlib/pyrevit/revit/geom.py
def convert_point_to_metric(rvt_point):
    """Convert given point coordinates to metric."""
    return DB.XYZ(rvt_point.X * 0.3048, rvt_point.Y * 0.3048, rvt_point.Z * 0.3048)