I have been searching for automatic dimensioning everywhere, but only found architectural dimensioning.
I’m working with electrical elements that seemingly just work different.
I can extract Points from them and create line in between etc.
But the Dimension.ByElement does not accept Lines as such.
Kinda stuck at this point.
More or less. The references are the main reference lines in the element family “Center (Left/Right)” and “Center (Top/Bottom)” and any named reference lines that have been added manually.
I’ve tried retrieving them somehow, even drawn a reference line in the family myself, and i can’t seem to get them.
Also any type of dimensioning node i’m using is always never satisfactory about the data it receives.
Show the graph of what you set up for getting and using the references. Most every family should have the main references as I previously stated. The intersection of those is the insertion point origin for the family. If you manually add reference lines, make sure you name them and set them to a reference type (strong, weak, etc.) else you won’t be able to retrieve them.
Here is some code that may make it easier to pull the references by their names. Make sure your reference name or names is in a list format and the name is inputted exactly as it is in the family (as shown in the clip below).
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]
refnames = IN[1]
reference=[]
planes=[]
names=[]
TransactionManager.Instance.EnsureInTransaction(doc)
for e in elements:
for rf in refnames:
refs = e.GetReferenceByName(rf)
if refs is not None:
reference.append(refs)
for r in reference:
name = (e.GetReferenceName(r))
names.append(name)
for ref in reference:
sketchPlane = SketchPlane.Create(doc, ref)
planes.append(sketchPlane.GetPlane().ToPlane(True))
TransactionManager.Instance.TransactionTaskDone()
OUT = reference, planes, names
The above code is embedded in the “Get Family Reference By Reference Name” code block.
Thanks for the code, it definitely gets references from the family types.
Also i have been trying multiple ways of delivering the correct data to the Dimensioning node, but nothing works.
This is the latest state of my script:
You need the Dynamo reference to the Revit reference - basically you need to wrap the element. This should be done in your Python, but I cannot tell you how or why as you haven’t shared that code.
Hereby i will attach everything involved with my work. It hasn’t changed much though.
Hopefully you can spot what is wrong with my graph and i hope this is enough data about this problem.
Here is a basic test script with the results. Using the OOTB Dimension.ByReferences node as you have, gave me the same error. But the GeniusLoci node works correctly.
Actually i am working with separate dimensions for each symbol, but i have solved that with the codeblock script and using level-2 on the ‘References’ input slot