Location point of independenttag

Hello,
Does anyone know to extract the location point of an independent tag?

Thanks

jckh

Hello mr. Kahre:

Here’s how to move a tag to a new location:
(Tags doesn’t have a location point, use tag.TagHeadPosition instead)

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure 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

#Preparing input from dynamo to revit
tag = UnwrapElement(IN[0])
newPoint = IN[1].ToXyz()


TransactionManager.Instance.EnsureInTransaction(doc)

tag.Location.Move(newPoint - tag.TagHeadPosition)

TransactionManager.Instance.TransactionTaskDone()
OUT = IN[0]
1 Like

Hey Einar,

thanks for the quick reply…
but i’m actually looking for the location point of the tag.

Hi @Jan_Christoph_Kahre

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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


doc = DocumentManager.Instance.CurrentDBDocument

tag = UnwrapElement(IN[0])
xyz = tag.TagHeadPosition.ToPoint()



OUT = xyz


";

Here’s a code that will work whether you input a sigle tag element or a list of tag elements

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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


doc = DocumentManager.Instance.CurrentDBDocument

tags = []
xyz = []

if isinstance(IN[0],list):
	for i in IN[0]:
		tags.append(UnwrapElement(i))
	for t in tags:
		xyz.append(t.TagHeadPosition.ToPoint())
else:
	tags = UnwrapElement(IN[0])
	xyz = tags.TagHeadPosition.ToPoint()


OUT = xyz
2 Likes

Thank you @Mostafa_El_Ayoubi, if you remove the first and last quotes the code gets the right formatting.

@Jan_Christoph_Kahre: I know, but the point was in there. I just had that example lying around.

got it :wink:

I actually like to wrap the python node in a custom node, that way dynamo will handle the lists for you. That will work for all kinds of list structures. Se this post from Dimitar:

1 Like

Awesome…

It works.

Thanks anyone

jckh

@Einar_Raknes
Thanks I did not know that! I’m still in the process of learning python and I like the live interaction while using python script from string …

Is there a way to get the Leader Point of the Independent Tag. I am noticing everything I am seeing is the Head Position. I am trying to move the Leader Point from the center of pipe to edge of pipe. @Mostafa_El_Ayoubi