# Area Tag Set TagHeadPosition / setting attributes

**URL:** <https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069>\
**Category:** Revit\
**Tags:** python\
**Created:** [February 14, 2024, 8:11am UTC](https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069 "2024-02-14T08:11:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ira.yap](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@ira.yap](https://forum.dynamobim.com/u/ira.yap)\
**Post date:** [February 14, 2024, 8:11am UTC](https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069/1 "2024-02-14T08:11:19Z")

</div>

Good day!

Python newb here, I am trying to get and set the head position for area tags, but Im having trouble getting any packages to work for area tags. I modified a python script for getting TagHeadPosition but having trouble using it to setting TagHeadPosition. I am familiar with setting parameters with python but how does it differ from setting attributes?  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/e/2e02dfb826045e9e7cc4d4ce4a7a05e5ca40cad2.png)

```auto
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])]
    
pts = IN[1]
    
listout =[]

for x in tags:
    y = x.TagHeadPosition
    TransactionManager.Instance.EnsureInTransaction(doc)
    setattr(x, y, pts)
    TransactionManager.Instance.TransactionTaskDone()
    

```

---

<div class="post-metadata">

**Author:** ![ira.yap](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@ira.yap](https://forum.dynamobim.com/u/ira.yap)\
**Post date:** [February 16, 2024, 2:49am UTC](https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069/2 "2024-02-16T02:49:02Z")

</div>

Hello, I still need a solution for this 🙂 . I have made progress and the code seems to work but is not reflecting on Revit itself. Is this a transaction manager issue?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/d/7d80613bb995f5696a47f8348ee9fb5fdbe9ec79.png)

From checking with another custom node the input and output values seem to align, however the changes dont seem to be reflected on Revit:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/1/71d64a42bdb65f5abf65db8a918227e56d996315.jpeg)

```auto
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB import AreaTag
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument
# Convert Dynamo inputs to Revit elements
if isinstance(IN[0], list):
    area_tags = [UnwrapElement(tag) for tag in IN[0]]
else:
    area_tags = [UnwrapElement(IN[0])]
# Convert Dynamo points to Revit XYZ points
if isinstance(IN[1], list):
    points = [pt.ToXyz() for pt in IN[1]]
else:
    points = [IN[1].ToXyz()]
# Ensure that the number of points matches the number of area tags
if len(area_tags) != len(points):
raise ValueError("Number of area tags and points do not match.")
# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# Set the TagHeadPosition for each area tag to its corresponding point
for tag, point in zip(area_tags, points):
if isinstance(tag, AreaTag):
        tag.HasLeader = True
        tag.LeaderEndCondition = LeaderEndCondition.Free
        tag.TagHeadPosition = point
# Commit the transaction
TransactionManager.Instance.TransactionTaskDone()
# Output the modified area tags
OUT = area_tags

```

---

<div class="post-metadata">

**Author:** ![hamid-dpr](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@hamid-dpr](https://forum.dynamobim.com/u/hamid-dpr)\
**Post date:** [February 16, 2024, 11:23pm UTC](https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069/3 "2024-02-16T23:23:20Z")

</div>

I tested this with Revit 2022, and it seems it is a bug.

If you add a subsequent process in python/dynamo that changes something else in the tag too, you will see it will apply the move. e.g., I changed the Angle property to 1 and back to 0 after running your node.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/59a47ccdf142f58b85e788f33183a2a33a68e752.jpeg)

---

<div class="post-metadata">

**Author:** ![ira.yap](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@ira.yap](https://forum.dynamobim.com/u/ira.yap)\
**Post date:** [February 19, 2024, 12:24am UTC](https://forum.dynamobim.com/t/area-tag-set-tagheadposition-setting-attributes/98069/4 "2024-02-19T00:24:02Z")

</div>

Thank you Hamid! I appreciate the response! This should work for what I need 🙂
