I’m using GeniusLoci (v2022.8.5) to create dimensions by references. The references are a list of list. It works well when all the elements are face references or when all the elements are edge references. However, when the list of list contains a mix of face and edge references, it doesn’t always create the dimension.
The code looks correct so not sure why this is happening.
#Alban de Chasteigner 2019
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
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 = [], []
#Thanks to Gavin Crump for the list structure improvement
for references in referenceList :
elementsRef = ReferenceArray()
for reference in references :
elementsRef.Append(reference)
listRef.append(elementsRef)
TransactionManager.Instance.EnsureInTransaction(doc)
for view in views:
dims = []
for line,refer in zip(lines,listRef) :
if doc.IsFamilyDocument == True :
if IN[3]== None:
dims.append(doc.FamilyCreate.NewDimension(view, line.ToRevitType(), refer).ToDSType(True))
else:
dims.append(doc.FamilyCreate.NewDimension(view, line.ToRevitType(), refer, dimensionType).ToDSType(True))
else:
if IN[3]== None:
dims.append(doc.Create.NewDimension(view, line.ToRevitType(), refer).ToDSType(True))
else:
dims.append(doc.Create.NewDimension(view, line.ToRevitType(), refer, dimensionType).ToDSType(True))
dimList.append(dims)
TransactionManager.Instance.TransactionTaskDone()
if isinstance(IN[0], list): OUT = dimList
else: OUT = dimList[0]
Any suggesions?
An alternative approach is to only use edges (and no faces). But the elements in question are structural framing and the Compound Edge References node only seems to return edges if coping has been applied. (I’m aware it was designed for wall, floors, etc and not structural framing).