'Dimension' object has no attribute 'References'

I’m working with some Dimensions, and want to call the Dimension.References property, but i get an error

‘Dimension’ object has no attribute ‘References’

if i look at the dir of my Dimension object, this is verified. Am i missing something here? The Property is accessible through RevitLookup. I checked the Genius Loci node ‘Dimension Properties’ and it fetches the references using this property. I’m able to access the property ‘Value’, so i don’t think it’s a dependency issue. Maybe are some properties only accessible after the transaction has been committed?

      <class 'Revit.Elements.Dimension'>,
      [
        AboveValue,
        AreJoined,
        BelowValue,
        BoundingBox,
        ByEdges,
        ByElementDirection,
        ByElements,
        ByFaces,
        ByReferences,
        Curves,
        Delete,
        Dispose,
        ElementCurveReferences,
        ElementFaceReferences,
        ElementType,
        Equals,
        Faces,
        Finalize,
        Geometry,
        GetCategory,
        GetChildElements,
        GetHashCode,
        GetHostedElements,
        GetIntersectingElementsOfCategory,
        GetJoinedElements,
        GetLocation,
        GetMaterials,
        GetParameterValueByName,
        GetParentElement,
        GetType,
        Id,
        InternalElement,
        InternalElementId,
        InternalUniqueId,
        IsAlive,
        IsFrozen,
        IsHiddeninView,
        IsPinned,
        JoinGeometry,
        MemberwiseClone,
        MoveByVector,
        Name,
        Overloads,
        OverrideColorInView,
        OverrideInView,
        OverridesInView,
        Parameters,
        Prefix,
        ReferenceEquals,
        SafeInit,
        SetAboveValue,
        SetBelowValue,
        SetGeometryJoinOrder,
        SetLocation,
        SetParameterByName,
        SetPinnedStatus,
        SetPrefix,
        SetSuffix,
        SetValueOverride,
        Solids,
        Suffix,
        Tessellate,
        ToString,
        UniqueId,
        UnjoinAllGeometry,
        UnjoinGeometry,
        Value,
        ValueOverride,
        __call__,
        __class__,
        __delattr__,
        __delitem__,
        __dir__,
        __doc__,
        __enter__,
        __eq__,
        __exit__,
        __format__,
        __ge__,
        __getattribute__,
        __getitem__,
        __gt__,
        __hash__,
        __init__,
        __init_subclass__,
        __iter__,
        __le__,
        __lt__,
        __module__,
        __ne__,
        __new__,
        __overloads__,
        __reduce__,
        __reduce_ex__,
        __repr__,
        __setattr__,
        __setitem__,
        __sizeof__,
        __str__,
        __subclasshook__,
        get_AboveValue,
        get_BelowValue,
        get_BoundingBox,
        get_Curves,
        get_ElementCurveReferences,
        get_ElementFaceReferences,
        get_ElementType,
        get_Faces,
        get_GetCategory,
        get_Id,
        get_InternalElement,
        get_InternalElementId,
        get_IsAlive,
        get_IsPinned,
        get_Name,
        get_OverridesInView,
        get_Parameters,
        get_Prefix,
        get_Solids,
        get_Suffix,
        get_UniqueId,
        get_Value,
        get_ValueOverride,
        set_InternalElementId
      ],

i’m writing a procedure to iteratively remove references during dimension creation to eliminate creation of dimensions with ‘0’ values. Here’s what i’m using

# ------------------IMPORTS------------------
import clr
# Include these lines to access python modules
import sys

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

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.Exceptions import *  # enable this for debugging

# clr.AddReference('RevitAPIUI')
# from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

# There are namespace overlaps between ProtoGeometry and RevitNodes
# Be sure to address these discrepancies
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

# -----------------FUNCTIONS-----------------
toList = lambda x: x if isinstance(x, list) else [x]

def remove_from_RefArray(rArray, ind):
    trace.append("remove ind: {0} from ReferenceArray".format(ind))
    i = 0
    iter = rArray.GetEnumerator()
    new_RefArray = ReferenceArray()
    while iter.MoveNext():
        trace.append("  -check index {0}".format(i))
        if i != ind:
            trace.append("add to new array")
            new_RefArray.Append(iter.Current)
        i += 1
    return new_RefArray
    
# ------------------INPUTS-------------------

# Preparing input from dynamo to revit
views = toList(UnwrapElement(IN[0]))
lines = toList(IN[1])
if any(isinstance(el, list) for el in IN[2]):
    referenceList = IN[2]
else:
    referenceList = [(IN[2])]
dimensionType = toList(UnwrapElement(IN[3]))[0]
listRef, dimList = [], []

result = []
trace = []

# -------------------MAIN--------------------

for references in referenceList:
    elementsRef = ReferenceArray()
    for reference in references:
        elementsRef.Append(reference)
    listRef.append(elementsRef)

dimCheck = False

for view in views:
    dims = []
    for line, refer in zip(lines, listRef):
        t = Transaction(doc)
        
        while not dimCheck:
            t.Start("create-dimension")
            # create dimension
            if IN[3] is None:
                dim = doc.Create.NewDimension(view, line.ToRevitType(), refer).ToDSType(True)
            else:
                dim = doc.Create.NewDimension(view, line.ToRevitType(), refer, dimensionType).ToDSType(True)
            trace.append("dimension created")
            # check dim values for 0
            vals = dim.Value
            trace.append("Values: {0}".format(vals))
            trace.append(0 in vals)
            if 0 in vals:
                dimCheck = False             
                t.RollBack()
                i_remove = vals.index(0)+1
                trace.append("remove reference at ind = {0}".format(i_remove))
                trace.append(str(type(dim)))
                trace.append(dir(dim))
                trace.append(str(type(refer)))
                trace.append(refer)
                refer = remove_from_RefArray(refer, i_remove)
                #del refer[i_remove]
                trace.append("updated references")
                trace.append(refer)             
            else:
                trace.append("valid dim created")
                dimCheck = True
                result.append(dims)
                #t.Commit()
                t.Dispose()

# ------------------OUTPUT-------------------
OUT = result, trace

oh, i think i found it. the created dimensions are converted ToDSType, so the object dim is type: Revit.Elements.Dimension and not Autodesk.Revit.DB.Dimension

3 Likes