Tagging rooms - Python explanation required of 'ViewPlan is not Iterable'

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.
Tag%20rooms%20python%20Error


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)

Hello. When the error is something “is not Iterable” it basically means you are treating some single object as a list.

In this script, it is expecting a list of views as the input 1. An easy solution is to just use a List.Create using the view from Document.ActiveViewFromCurrentDocument as the only input and then connect to the Python node.

This is your issue:
for room, view in zip(rooms, views):

You’re saying “for each pair, room and view, in their respective lists of rooms and views…” This would require matching list lengths with each room having a paired view. If you only have a single view that is going to be used for all rooms you would just use for room in rooms: and then call the same view for each one.

2 Likes