Location point of independenttag


#1

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

Thanks

jckh


#2

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]

#3

Hey Einar,

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


#4

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


";

#5

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

#6

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.


#7

got it :wink:


#8

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:


#9

Awesome…

It works.

Thanks anyone

jckh


#10

@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 …