Dimension.byfaces

Hi, I’m pretty sure I have the top and bottom face of the door leaf on the right plane for dimensioning but I get this error when trying to. I tried with the placement line at the view and at the family location point. Am I doing something silly? :upside_down_face:

Hi @vanman looks right :wink: probably a family thing, could you share that door ?

Thanks Sovitek, I was wondering if its because of nested families inside the door, when I through tons of references at it a dimension would pop up but it got stuck in this loop where you could never remove whatever other dimensions it made. Please see below.

IGL_45_Hinge 1.rfa (1.0 MB)

When I tested with a R23 sample door this happened. I’m drawing a detail line in the view for the placement line. Its not getting the surface on the plane I expected.


1 Like

Hi @vanman i can only get it to work with by.edges with ootb on your family…havent tried with genius loci…could probably be better

1 Like

Awesome! Is it possible to get those edge references from the element geometry?

1 Like

yes should be possible…just some sorting i guess :wink: :wink:

I shall try tomorrow. My eyes hurt. :joy: I have a sneaking suspicion I’ve been down this road and couldn’t get them.

yeahh should work…but worth try genius loci as well :wink:

1 Like

So I got AI to get DB.references of edges which I’m pretty sure I can use to dimension too and the reference geometry to it for filtering. However It gives me the geometry at 0. I need it at the door to use some other elements of the door for filtering. I’m at a stalemate with AI in getting it to transform the geometry back to the door. Does anyone have a reference to some transforming geometry code I could feed it to help? Or another method of getting DB.reference geometry in the location of the door? @jacob.small? :face_with_peeking_eye:

The stuck code. www.perplexity.ai has been really great with dynamo code stuff.

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument

# Helper function to convert Revit Transform to Dynamo CoordinateSystem
def transform_to_coordinate_system(transform):
    origin = Point.ByCoordinates(transform.Origin.X, transform.Origin.Y, transform.Origin.Z)
    basisX = Vector.ByCoordinates(transform.BasisX.X, transform.BasisX.Y, transform.BasisX.Z)
    basisY = Vector.ByCoordinates(transform.BasisY.X, transform.BasisY.Y, transform.BasisY.Z)
    basisZ = Vector.ByCoordinates(transform.BasisZ.X, transform.BasisZ.Y, transform.BasisZ.Z)
    return CoordinateSystem.ByOriginVectors(origin, basisX, basisY, basisZ)

# Function to get edge references and their Dynamo geometry from nested families in a door family
def get_edge_references_and_dynamo_geometry(door):
    edge_refs = []
    dynamo_geometries = []
    options = Options()
    options.ComputeReferences = True  # Ensure references are computed
    
    # Get geometry of the door
    geomElement = door.get_Geometry(options)
    
    if geomElement is not None:
        for geomObj in geomElement:
            if isinstance(geomObj, GeometryInstance):
                symbolGeometry = geomObj.GetSymbolGeometry()
                if symbolGeometry is not None:
                    # Get the transformation of the door instance
                    transform = geomObj.Transform
                    dynamo_transform = transform_to_coordinate_system(transform)
                    for geom in symbolGeometry:
                        if isinstance(geom, Solid):
                            for edge in geom.Edges:
                                if edge.Reference is not None:
                                    edge_refs.append(edge.Reference)
                                    # Convert Revit geometry to Dynamo geometry
                                    dynamo_curve = edge.AsCurve().ToProtoType()
                                    # Apply transformation to the Dynamo geometry
                                    transformed_curve = dynamo_curve.Transform(dynamo_transform)
                                    dynamo_geometries.append(transformed_curve)
    
    return edge_refs, dynamo_geometries

# Recursive function to flatten the input list
def flatten(input_list):
    if isinstance(input_list, list):
        for item in input_list:
            for sub_item in flatten(item):
                yield sub_item
    else:
        yield input_list

# Input: List of doors (can be nested lists)
doors_input = IN[0]

# Flatten the input list
doors = list(flatten(UnwrapElement(doors_input)))

# Get edge references and Dynamo geometries from nested families
structured_output = []
for door in doors:
    edge_refs, dynamo_geoms = get_edge_references_and_dynamo_geometry(door)
    structured_output.append([edge_refs, dynamo_geoms])

OUT = structured_output

AI won’t help you here as 99.99999% of it is trained for not this case. Abandon your GPT and read the docs and develop your own intelligence.

This line seems suspect to me:
symbolGeometry = geomObj.GetSymbolGeometry()

Why are you asking for the geometry of the Symbol instead of the geometry of the instance? Check the GeometryInstance class as it feels like the solution will be staring you in the face.

OUT = dir(GeometryInstance) or check the Revit API docs. :slight_smile:

Code that works

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument

# Function to get edge references and their Dynamo geometry from nested families in a door family
def get_edge_references_and_dynamo_geometry(door):
    edge_refs = []
    dynamo_geometries = []
    options = Options()
    options.ComputeReferences = True  # Ensure references are computed
    geomElement = door.get_Geometry(options)
    
    if geomElement is not None:
        for geomObj in geomElement:
            if isinstance(geomObj, GeometryInstance):
                symbolGeometry = geomObj.GetSymbolGeometry()
                if symbolGeometry is not None:
                    for geom in symbolGeometry:
                        if isinstance(geom, Solid):
                            for edge in geom.Edges:
                                if edge.Reference is not None:
                                    edge_refs.append(edge.Reference)
                                    # Convert Revit geometry to Dynamo geometry
                                    dynamo_geometries.append(edge.AsCurve().ToProtoType())
    return edge_refs, dynamo_geometries

# Recursive function to flatten the input list
def flatten(input_list):
    if isinstance(input_list, list):
        for item in input_list:
            for sub_item in flatten(item):
                yield sub_item
    else:
        yield input_list

# Input: List of doors (can be nested lists)
doors_input = IN[0]

# Flatten the input list
doors = list(flatten(UnwrapElement(doors_input)))

# Get edge references and Dynamo geometries from nested families
structured_output = []
for door in doors:
    edge_refs, dynamo_geoms = get_edge_references_and_dynamo_geometry(door)
    structured_output.append([edge_refs, dynamo_geoms])

OUT = structured_output

A likely simpler step would be to get the instance geometry instead of the symbol’s geometry via this method.

From there you can do the same ‘if solids’ and then ‘for edge if edge.Reference’. But if it ain’t broke… :slight_smile:

Are you saying get instance geometry and then get DB.Reference from that or visa versa? Or either way works?

¨Hi @vanman i would try with genius loci…as it seems your doors bottom reference isnt valid…guess it should be fixed in the family…here with genius loci

Revit_t1637q0t6E

2 Likes

So I cant actually tag any edge geometry reference on a door or any other object and I’ve been wasting hours? :rofl: It has to be actual refence lines then geometry?

I can actually just get the solids of the door in the same location to, to filter to correct edges and thus references… If I can actually dim to them… which I need to test

Ok so what I’m saying seems to be true, unless there’s another way anyone knows of. Got the DB.References of the door leaf edge and using genius locis node it spits out a dimension but randomly attaches to something else which I’m assuming is an actual reference plane inside the door.

It’s not. Can’t look at this for awhile though - on vacation for two weeks.

I recall the need to look for point references not edges as edges which are not perpendicular to the view will cause issues.

Have a lovely vacation! I shall investigate. Otherwise Ill give the user the option to dimension the wall opening of the door or the leafs but let them know itll draw detail lines on the door schedule view for that.

1 Like