Hi there,
I was having trouble getting the ‘Create Annotation Tag’ to place a room tag. I did a bit of hunting and found in the comments section of the nodes web-page (http://archi-lab.net/element-tagging-with-dynamo/) that room tags are not classed as an annotation category, and some Python code was posted as a solution.
I have copied the code over (annoyingly time consuming) but I have run into the following errors.
Can anyone explain why it is not taking the view input, and what it means by ‘not iterable’?
The code is:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
#Import Documentmanager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
#The inputs to this node will be stored as a list in the IN variable
dataEnteringNode = IN
rooms = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])
familyType = UnwrapElement(IN[2])
runMe = (IN[3])
#"start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
test = []
if runMe:
roomTags = []
for room, view in zip(rooms, views):
roomId = LinkeElementId(room.Id)
bbox = view.CropBox
XYZLocation = (bbox.Max + bbox.Min) / 2.0
location = Autodesk.Revit.DB.UV(XYZLocation.X + 0.2, XYZLocation.Y - 5.6)
roomTag = doc.Create.NewRoomTag(RoomId, location, view.Id)
roomTag.RoomTagType = familyType
roomTags.append(roomTag)
else:
roomTags = "Run Me set to False"
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable
OUT = roomTags
File download: Tag just bathrooms.dyn (20.5 KB)