Extract 2 intersection points(X,Y and Z) of 3 reference planes from Revit family

Greeting,

Extract 2 insertion points(X,Y and Z) of 3 reference planes(“Left“, “Right“,“Center((Front/Back)“) from Revit family in project. Z value is the same as the family’s insertion’s elevation.

As shown below

The sample Revit family is attached.

E.rfa (408 KB)

Thank you for the help in advance.

What have you tried so far? What issues are you running into? Have you accessed the family in the Family Editor environment? Can you get the reference plane geometry?
How to get help on the Dynamo forums - FAQ - Dynamo

Intersecting two planes is a no-no for ASM as the resulting curve is unbound. As such this gets a bit odd, but there is a simple fix should you have all planes perpendicular to each other.

However even though two planes intersecting would result in a rat, @Steven2026 indicated a point is the expected result, so I’m going to assume these planes are perpendicular to the internal XY plane.

Good code would check the angle between the normal of the front/back plane to the left and right planes to assure this is the case but I will assume that @Steven2026 has already done this manually or can implement similar if needed.

  1. Generate a point at the origin.
  2. Get the closed point on the front/back plane to the point.
  3. Get the closest point on both the left and the right plane from the projected point.

As the closest point to any plane is always normal to its face and the planes are perpendicular to each other this should return the points which are targeted.

If the desired elevation is another named reference plane you can first confirm it’s normal is also perpendicular, and then get the closest point on that plane from the projected points on the left and right plane.

Hi,

A workaround using temporary dimensions.

import clr
import sys
import System
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

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

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

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)

toList = lambda x : x if hasattr(x, "__iter__") and not isinstance(x, (str, System.String)) else [x]

#Preparing input from dynamo to revit
lstelems = toList(UnwrapElement(IN[0]))
lst_plane_name = toList(IN[1])
out = []

TransactionManager.Instance.EnsureInTransaction(doc)
for instance in lstelems:
    basisX = instance.GetTransform().BasisX
    base_line = DB.Line.CreateUnbound(instance.Location.Point, basisX)
    plane_RefA = instance.GetReferenceByName(lst_plane_name[0])
    plane_RefB = instance.GetReferenceByName(lst_plane_name[1])
    ref_array = ReferenceArray()
    ref_array.Append(plane_RefA)
    ref_array.Append(plane_RefB)
    # create a temporary dimension
    dim = doc.Create.NewDimension(doc.ActiveView, base_line, ref_array)
    doc.Regenerate()
    curvDim = dim.Curve
    direction = curvDim.Direction
    # get points
    start = dim.Origin - (direction * ( dim.Value/2))            
    end = dim.Origin - (direction * (-1 * dim.Value/2 ))    
    out.append([start.ToPoint(), end.ToPoint()])
    # remove dimension
    doc.Delete(dim.Id)
    
TransactionManager.Instance.TransactionTaskDone()
OUT = out
1 Like

Thank you so much for the help. This is exactly what I need. The full script as below just incase if anyone wants to use it.

1 Like