Get endpoint of Leader of Independent Tag

I am needing to Get all the leader end points of Tags to Pipes. The pipes being tagged are in a linked model. So Dynamo sees the pipe Tags as Independent tags. The OOTB Nodes for getting the Leader End point do not recognize Independent Tags. I have found Nodes from the Packages MEPover and GeniusLoci that will Get the Host Tag Position. I am hoping it is as easy as updating the code, but I am not familiar with how to find the command for Leader end Instead of TagHostPosition.

import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
if isinstance(IN[0], list):
	tags = UnwrapElement(IN[0])
else:
	tags = [UnwrapElement(IN[0])]
listout = []
for x in tags:
	loc = x.TagHeadPosition.ToPoint()
	listout.append(loc)
OUT = listout

Long Story Short, I am trying to move all the Attached pipe tags that are to the center of the pipe, make them free end and move the leader to edge of pipe. I can get this to work when the pipes are not in a linked model and I am tagging from the same model, but when the pipes are in a linked model it will not work because the nodes get errors with Independent Tags instead of them being PipeTags.
Thanks, sorry for the long post. :slight_smile:

1 Like

@jtmiller ,

i get a point :wink: BUT i cleaned up your code.

i think its not correct

import sys
import clr

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

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

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

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


if isinstance(IN[0], list):
    tags = UnwrapElement(IN[0])
else:
    tags = [UnwrapElement(IN[0])]
    
listout =[]

for x in tags:
    loc = x.TagHeadPosition.ToPoint()
    listout.append(loc)
    
OUT = listout

Thank you @Draxl_Andreas for the rewrite. I might have not described my problem incorrectly. I am looking to get the Leader End point instead of the TagHeadPosition. Do you think you could update that? I am not sure what to update TagHeadPosition with.

@jtmiller ,

seems not to be exposed … hmmm

Hello
a workaround by temporarily setting the LeaderEndCondition to free

get end leader

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

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
sdkNumber = int(app.VersionNumber)

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


def setFreeEnd_temp(func):
	def wrapper(*args, **kwargs):
		tag = args[0]
		TransactionManager.Instance.ForceCloseTransaction()
		t = Transaction(doc, func.__name__)
		t.Start()
		tag.LeaderEndCondition = LeaderEndCondition.Free
		doc.Regenerate()
		ret = func(*args, **kwargs) 
		t.RollBack()
		t.Dispose()
		return ret 
	return wrapper 

@setFreeEnd_temp
def get_endpoint_of_Tag(tag):
	if sdkNumber < 2022:
		return tag.LeaderEnd.ToPoint()
	else:
		ref = next(e for e in tag.GetTaggedReferences())
		return tag.GetLeaderEnd(ref).ToPoint()

tag = UnwrapElement(IN[0])
OUT = get_endpoint_of_Tag(tag)
2 Likes

Thank You! I will give this a try and let you know. I seem to have problems when it comes to Python stuff. Is it as simple as copy and paste into the Python Node?

it’s an example for 1 element, you just need to adapt the code for an input list