GetRodEndPosistion Method

Good morning All,

I am attempting to get the coordinates of hanger rods in my revit model and return the value to me. I am not able to achieve this strictly through dynamo though. I am attempting to formulate a python script to assist in this and have found the proper method in the Revit API docs. It’s the GetRodEndPosistion Method. I have been taking python courses but have not figured it out. Any help would be appreciated. If more information is needed, please let me know.

Thanks

This is where I am at.

image

Assuming your input items are the hanger rods you can try something like this.

items = UnwrapElement(IN[0])
OUT = [i.GetRodEndPosition() for i in items]

My inputs are actually the hangers that have rods built in.

image

The above is the warning I get when using what you have supplied.

The method GetRodEndPosition() is defined on the API under the FabricationRodInfo Class.
So assuming your inputs are hanger rods (FabricationParts) you will need to use the method GetRodInfo() (see link) and from this, the method GetRodEndPosition() (see link)

I haven’t tried, but following same logic as @Mostapha, something like:

items = UnwrapElement(IN[0])
rodInfo = [i.GetRodInfo() for i in items]
OUT = [rodInfo.GetRodEndPosition() for i in items]

Thank both of you for the replies.

Using your code I receive this warning.

image

Do I need to import another module to get this to work? I looked at the Revit API docs but it seems if I import the Revit API I should be covered. And yes, my inputs are fabrication parts.

Might be due to how your input is structured.
It will be better if you could share an image of your whole graph, or even better the file :slight_smile:

This is it in all its glory. Adding a List.Create node didn’t seem to help.

today.dyn (2.9 KB)

ok, after reading the API more in depth, this should work (at least it does at my end) :slight_smile:

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

items = UnwrapElement(IN[0])
rodInfo = [i.GetRodInfo() for i in items]
endPositions = []

for rInfo in rodInfo:
	rodCount = rInfo.RodCount
	ends =[]
	for j in range(rodCount):
		ends.append(rInfo.GetRodEndPosition(j).ToPoint())
	endPositions.append(ends)
	
OUT = endPositions

Works like a Charm. Thank you so much. I will continue to educate myself but needed justification for doing so (its a backwards process). Thank you again.

This does look completely different than what i imagined it would. I don’t the rhyme and reason to it. How did you get this out of reading the API more in depth? If this question is to much to answer, I understand and will find out one day.

I thought I’d be done after that but I have another issue. I get my coordinates but now I need to match those up with my “item number” parameter. When there is only one rod per hanger, it is no problem. But when I have 2 rods per hanger it messes up my list with how i am trying to achieve this. Does anybody know of a way to get this done. See below graph.

today2.dyn (7.5 KB)