How to Get Edge References (for Dimensioning)

I can’t help noticing that Dynamo 2.12 has added some new nodes for dimensioning elements in Revit.
Dimension nodes #2632
I’ve had some great success with the Dimension.ByReferences Node. The face references a not difficult to get:

The ability to get face references from dynamo surfaces is great because it means that you can generate dimensions for an object without actually having to select it! However, things get more tricky with edge references. Dimension.ByEdges is a node now and I have been able to generate dimensions with it, but only if I select them directly with a ‘Select Edge’ Node. You can see what I mean below:


The prospect of having to select edges directly in order to dimension them seems a bit counterintuitive.
Is there a way to get edge references without actually selecting an edge? I tried the ‘Face.Edges’ node; apparently the input requires an actual ‘face’ that is somehow yielded by something other than the ‘Select Face’ node. :thinking:

Does anyone know how to get ‘faces’ instead of ‘surfaces’? Maybe then it’s possible to get curve references from the edges.

Try Element.Geometry > Topology.Faces

Thanks Jacob,
I can get the actual faces now! Maybe I am one step closer.


It seems like the ‘ElementCurveReference.ByCurve’ node only likes to accept a certain type of curve; maybe its a model curve?
From Face.Edges I get this error:
Warning: ElementCurveReference.ByCurve expects argument type(s) (Autodesk.DesignScript.Geometry.Curve), but was called with (Autodesk.DesignScript.Geometry.Edge).
From Edge.CurveGeometry I get this:
Warning: ElementCurveReference.ByCurve operation failed.
This node requires a ElementCurveReference extracted from a Revit Element! The input curves should come from a Revit Element. You can use the ModelCurve.ByCurve or ImportInstance.ByGeometry to turn this Curve into a Revit Element.

I thought I’d try it perimeter curves too. It seems like Dynamo loses the association between an element edge and a dynamo curve when it is pulled from geometry.


I get a similar error; Dynamo thinks that the reference is not from an element created in Revit.
I wonder if there is a way to get the element curves more directly, without manually selecting them :thinking:

@Alban_de_Chasteigner has some great nodes from the Genius Loci Package that do just this.


I really wish I had the highlighted references though.
The package also contains a compound edges option.

So close! The needed edges are retrieved, but the horizontal references are not given.

1 Like

The edges that are perpendicular to the view plane are super useful for dimensioning angled things.

(Selections below)


Can’t do that with face references!
Does anyone know how to get all of the edge references for an element? They don’t need to be sorted by vertical and horizontal, the list of edge curves and list of edge references just needs to be in the same order.

So… I opened up @Alban_de_Chasteigner’s node ‘Compound Edges References’ and made some adjustments to the python script. It is below:

#Alban de Chasteigner 2019
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
#Edited By: Daniel Masten 2022

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

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

items = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]

def split_half(a):
	half = len(a) >> 1
	#return a[:half], a[half:]
	return a[half:]

allHorzEdges,allVertEdges,allVertReferences,allHorzReferences=[],[],[],[]

opt = Options()
opt.ComputeReferences = True
#opt.IncludeNonVisibleObjects = True
#opt.View = doc.ActiveView
for item in items:
	for obj in item.get_Geometry(opt):
		if isinstance(obj, Solid):
			gline = obj
			vertEdges,horzEdges,vertReferences,horzReferences=[],[],[],[]
			for edges in gline.Edges:
				if round(edges.AsCurve().GetEndPoint(0).ToPoint().Z,10) != round(edges.AsCurve().GetEndPoint(1).ToPoint().Z,10):
					vertEdges.append(edges.AsCurve().ToProtoType())
					vertReferences.append(edges.Reference)
				else:
					horzEdges.append(edges.AsCurve().ToProtoType())
					horzReferences.append(edges.Reference)
			if isinstance(item, Autodesk.Revit.DB.Wall):
				allHorzEdges.append(horzEdges)
				allHorzReferences.append(horzReferences)
			else:
				allHorzEdges.append(split_half(horzEdges))
				allHorzReferences.append(split_half(horzReferences))
			allVertEdges.append(vertEdges)
			allVertReferences.append(vertReferences)
		
if isinstance(IN[0], list): OUT = allHorzEdges,allVertEdges,allVertReferences,allHorzReferences
else: OUT = allHorzEdges[0],allVertEdges[0],allHorzReferences[0],allVertReferences[0]

Just as a disclaimer, it’s my first time editing python and somehow I think I managed to update the script without breaking it! My successful run is below:



I still need to clean out the 0, but that only requires a little extra filtering in the dynamo graph.

I realize that the python script could be simplified significantly; the separation of vertical references from all others does not need to occur. However, I am not yet ready for this feat. Someone with a little more knowledge of python could probably do it quite easily. To that end, the updated node is posted below:
EdgesReferences.dyf (13.8 KB)

Thanks

1 Like

Alright, so give me a day and a crash course in Python and we’ll see what we can do.
The revised platonic version of the python script that can get edges and respective references for a group or single object is below:

#Alban de Chasteigner 2019
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
#Edited By: Daniel Masten 2022

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

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

items = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]

allEdges,allReferences=[],[]

opt = Options()
opt.ComputeReferences = True
#opt.IncludeNonVisibleObjects = True
#opt.View = doc.ActiveView
for item in items:
	for obj in item.get_Geometry(opt):
		if isinstance(obj, Solid):
			elmtEdges,elmtReferences=[],[]
			for edges in obj.Edges:
				elmtEdges.append(edges.AsCurve().ToProtoType())
				elmtReferences.append(edges.Reference)
			allEdges.append(elmtEdges)
			allReferences.append(elmtReferences)
		
if isinstance(IN[0], list): OUT = allEdges,allReferences
else: OUT = allEdges[0],allReferences[0]

Here is the custom node:
EdgeReferences.dyf (9.7 KB)

For the editors of Dynamo OOTB nodes I have two recommendations:

  1. The node ‘ElementCurveReference.ByCurve’ needs to be modified so that it can accept edge curves that are in fact derived from revit faces. If the node ‘ElementFaceReference.BySurface’ can get a face reference from a surface, then curve references should be able to be extracted from that same surface’s edges too.
  2. It may be helpful to extract edge curves from an element directly, and it would make sense to do it with the 'Element.Curves node:

    If faces can be extracted from an element, lets be able to get those edges too.
    Thanks.
3 Likes

Hello Daniel,

Thanks for this thread and posts.

I was working on dimensioning of columns but have to give up because i could only use faces for dimensioning.

After reading your posts i have new hope that this is possible, i will start testing now.
My goal was to dimension a column like this:

Dimension Columns - Dimensioning by Points? - Revit - Dynamo (dynamobim.com)

So I´m not very lucky at dimensioning my column:

Hi Gerhard,
To start off, only the first node on the left will work with this type of reference. The OOTB nodes will not.
It also looks like you are plugging in a detail line into the dimension node. That needs to be converted to a dynamo line with the Element.GetLocation or Element.Geometry Node. If the line renders in the dynamo environment, you’ll be on the right track.

1 Like

I can´t believe it, that actually works :open_mouth:

Now i just have to find a method for getting the right edges. Maybe all edges with vector=viewdirection.

Made my day, thank you daniel :smiley:

2 Likes

After some testing, there are many columns that just gives empty lists:

Any idea what could be the problem @daniel1 , @Alban_de_Chasteigner ?

Edit: OK, funny, the code works only for unpinned elements! Have to set pinned status before:

No idea for the pinned elements.

But I updated the Compound Edges References node with a new Horizontal references output.
It seems to be useful for your workflows.

Compound Edges

5 Likes

Thank you very much Alban! :slight_smile:

But after replacing the node in the geniusloci folder i can´t find it in dynamo :thinking:

Maybe try to find it in the library by typing Compound Edges References.

2 Likes

With this file it´s working now :slight_smile:
Amazing how many reference nodes you created.

I asked a few times on the forum if it is possible to get point references and dimension to them but never got reply. But now there are nodes for point references in your package, I´m looking forward to test them!

So this works perfect for columns that don´t have horizontal top/bottom surfaces, im getting the 4 edges i want :smiley:

But for other cases i will still have to filter out the edges that are in view direction.
So as @daniel1 already mentioned, that edges that are in view direction are very useful.

1 Like