Why cant i create a dimention line here thanks

Hey guys, I came into a problem. I have this graph in which I am trying to make a dimension line between two references, which came out of the faces of a column. One of the nodes extracts the reference, and the other gets them and a detail line and is supposed to make the dimension line. For some reason, the dimension line is output, but I canโ€™t see it in the floor plan. If someone cares to take a quick look, it would be much appreciated.

Here is the first one that extracts the references:

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

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument

# Inputs from Dynamo
column = UnwrapElement(IN[0]) # Column as FamilyInstance
detail_curve = UnwrapElement(IN[1]) # ModelCurve or Line

# Ensure input is a FamilyInstance (column from a Family)
if not isinstance(column, FamilyInstance):
OUT = "Error: The input element is not a FamilyInstance", None
else:
# Set geometry options
options = Options()
options.ComputeReferences = True
options.IncludeNonVisibleObjects = True

geo = column.get_Geometry(options)

# Collect all solids from the column geometry
solids = []

for g in geo:
if isinstance(g, Solid)and g.Volume > 0:
solids.append(g)
elif isinstance(g, GeometryInstance):
inst_geo = g.GetInstanceGeometry()
for sg in inst_geo:
if isinstance(sg, Solid)and sg.Volume > 0:
solids.append(sg)

if len(solids) == 0:
OUT = "No solid found in column geometry", None
else:
# Prepare list to collect references of faces that have intersections
intersected_references = []
intersected_faces = []
for solid in solids:
for face in solid.Faces:
out_InterResultArray = IntersectionResultArray()
set_ComparisonResult, out_InterResultArray = face.Intersect(detail_curve.GeometryCurve, out_InterResultArray)

if set_ComparisonResult != SetComparisonResult.Disjoint:
intersected_references.append(face.Reference)
intersected_faces.append(face)
# Add only the Reference of the face

# Return list of face references (can be empty)
OUT = intersected_references

And the second one, how should create a dimension line

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
clr.AddReference('RevitNodes')
clr.AddReference('RevitServices')

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import traceback

doc = DocumentManager.Instance.CurrentDBDocument

# ืงื‘ืœืช ื”ืงืœื˜ ืž-Dynamo
face_references = IN[0]  # ืจืฉื™ืžื” ืฉืœ ืฉืชื™ ื”ืคื ื™ื•ืช ืœืคื ื™ื
line = UnwrapElement(IN[1])      # ืงื• ืคืจื˜ื™ื ืœื”ื’ื“ืจืช ืžื™ืงื•ื ืงื• ื”ืžื™ื“ื•ืช

def create_dimension_between_faces(face_refs, line):
    """
    ื™ืฆื™ืจืช ืžื™ื“ื•ืช ื‘ื™ืŸ ืฉืชื™ ืคื ื™ื
    """
    try:
        # ื‘ื“ื™ืงืช ืชืงื™ื ื•ืช ื”ืงืœื˜
        OUT = "Checking input validity..."  # ื‘ื“ื™ืงืช ืชืงื™ื ื•ืช ื”ืงืœื˜
        if not face_refs or len(face_refs) != 2:
            raise ValueError("ื—ื™ื™ื‘ ืœื”ื™ื•ืช ื‘ื“ื™ื•ืง ืฉืชื™ ื”ืคื ื™ื•ืช ืœืคื ื™ื")
        
        if not line:
            raise ValueError("ื—ื™ื™ื‘ ืœืกืคืง ืงื• ืคืจื˜ื™ื")
        
        # ืงื‘ืœืช ื”ืžืกืžืš ื•ื”ืชืฆื•ื’ื” ื”ืคืขื™ืœื”
        print("Getting active document and view...")  # ืงื‘ืœืช ื”ืžืกืžืš ื•ื”ืชืฆื•ื’ื”
        
        
        # ืงื‘ืœืช ื”ื’ื™ืื•ืžื˜ืจื™ื” ืฉืœ ื”ืงื•
        #print("Extracting line geometry...")  # ื—ื™ืœื•ืฅ ื’ื™ืื•ืžื˜ืจื™ื™ืช ื”ืงื•
        line_curve = line.GeometryCurve
        
        # ื™ืฆื™ืจืช ReferenceArray ืžื”ื”ืคื ื™ื•ืช ืœืคื ื™ื
        #print("Creating reference array...")  # ื™ืฆื™ืจืช ืžืขืจืš ื”ืคื ื™ื•ืช
        ref_array = ReferenceArray()
        for face_ref in face_refs:
            ref_array.Append(face_ref)
        
        # ื”ืชื—ืœืช ื˜ืจื ื–ืงืฆื™ื”
        #print("Starting transaction...")  # ื”ืชื—ืœืช ื˜ืจื ื–ืงืฆื™ื”
        TransactionManager.Instance.EnsureInTransaction(doc)
        
        # ื™ืฆื™ืจืช ื”ืžื™ื“ื•ืช
        #print("Creating dimension...")  # ื™ืฆื™ืจืช ื”ืžื™ื“ื•ืช
        dimension = doc.Create.NewDimension(doc.ActiveView, line_curve, ref_array)
        
        # ืกื™ื•ื ื”ื˜ืจื ื–ืงืฆื™ื”
        #print("Committing transaction...")  # ืกื™ื•ื ื”ื˜ืจื ื–ืงืฆื™ื”
        TransactionManager.Instance.TransactionTaskDone()
        
        #print("Dimension created successfully!")  # ื”ืžื™ื“ื•ืช ื ื•ืฆืจื• ื‘ื”ืฆืœื—ื”
        return dimension
        
    except Exception as e: 
        error_msg = "ืฉื’ื™ืื” ื‘ื™ืฆื™ืจืช ื”ืžื™ื“ื•ืช: " + str(e)
        print(error_msg)
        print(traceback.format_exc())
        return None

# ื”ืจืฆืช ื”ืคื•ื ืงืฆื™ื”
#"Starting dimension creation process..." # ื”ืชื—ืœืช ืชื”ืœื™ืš ื™ืฆื™ืจืช ื”ืžื™ื“ื•ืช
result = create_dimension_between_faces(face_references, line)

# ื”ื—ื–ืจืช ื”ืชื•ืฆืื” ืœ-Dynamo
OUT = result


one quick fix i can think of is u add a dimension manually first, then query its location or the height of its reference line. then u go back to ur creation logic of reference line and lift it to the same height uโ€™ve just got. the benefit of this is u donโ€™t have to worry abt whether itโ€™s a workplane or a cut plane issue. and speakin of annotations, these are 3d though they look 2d.

btw, i tagged ur post to get more attention.

hey thank you very much for the tagging and for answering. if the detail line is placed ontop of the floor plan isnt it saing is Z value is the same as the plan? witch indicate that it is the corect Z value.

thanks for the respoend!

Hi,

faces references are sometimes FamilySymbol references, instance references are required for dimensions

Here is an example with a workaround:

not quite i believe. detail line is bound to workplane. and workplanes could be anywhere. this z value issue is one of the possible causes which happened to be the one i always forgot when coming back to rvt. i lifted them up then they showed up.

1 Like

Hey, thanks for the advice. I tried it, but it doesnโ€™t seem to work either. I donโ€™t think it had something to do with the line because I managed to do the same thing in the past, and it worked. I will try one more thing and let you know about it. thanks again

no worries. i would go with cyrilโ€™s suggestion @c.poupin and after that, visibility, worksets and etc. cant wait to see what you discover finally.

1 Like