Trying to add legends to sheets

I’ve been working on automating adding legends to sheets. When we do our submittal, we add our detail legends to a 30x42 border. Starting from the upper left of the sheet, we have 2 rows of 5 legends, then 1 row of 4 legends. The lower right section of each sheet has stamps and stuff, so we put 14 legends on a sheet.

I tried to follow along with the solution here from @Daniel_Woodcock1, Place multiple views on multiple sheets by coordinates. Here is the end of my graph, the .dyn file is also attached below. The watch nodes along the bottom show what I’m plugging into the code block at the top of the image. I just noticed the code block is greyed out. The preview is off otherwise it would add the points to the model. Turning the preview back on doesn’t change anything about what’s happening here.

When it runs, it gives an error in the Python block:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 63, in <module>
AttributeError: 'str' object has no attribute 'Id'

Any thoughts on what I’m missing here? The full Python code is below so you don’t have to go hunting for it. I numbered line 63 in the Python code.

Add details to sheet.dyn (157.3 KB)

################### Import References ###################
import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

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

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Electrical import PanelScheduleSheetInstance as pssi
################### Definitions ###################
def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

def MoveSchedule(v):
	res = False

	bBox = v.get_BoundingBox(doc.GetElement(v.OwnerViewId))
	w = (bBox.Max.X - bBox.Min.X)
	l = (bBox.Max.Y - bBox.Min.Y)		
	tVec = XYZ(-w/2,l/2,0)
	try:
		ElementTransformUtils.MoveElement(doc,v.Id,tVec)
		res = True
	except:
		res = False
		
	return res
################### Inputs ###################
#get the bool in port IN[0]...
run = tolist(IN[0])[0]
#get the sheet in port IN[1] and UnwrapElement if not already...
sheetsIN = tolist(UnwrapElement(IN[1]))
#get the views in port IN[1] and UnwrapElement if not already...
viewsIN = tolist(UnwrapElement(IN[2]))
#get the points in port IN[2] (no need to unwrap as these are Dynamo Points)...
locsIN = tolist(IN[3])
################### Outputs ###################
outList = []
################### Script ###################
if run:
	# check if list lengths are the same (the views and locations will be lists of lists here, but the outermost list layer should all be the same length)
	if len(sheetsIN) == len(viewsIN) == len(locsIN):
		TransactionManager.Instance.EnsureInTransaction(doc)
		# loop through all lists (views and locs will be lists of lists)
		for sht,views,locs in zip(sheetsIN,viewsIN,locsIN):
			arr = []
			# test if number of views and number of locations match
			if len(views) == len(locs):
				# loop through all views and locations and try place them on sheet...			
				for v,l in zip(views, locs):
					canAddToSht = True;
					if v.ViewType != ViewType.Schedule and v.ViewType != ViewType.PanelSchedule:				
63					canAddToSht = Viewport.CanAddViewToSheet(doc, sht.Id, v.Id)								
					if canAddToSht:			
						try:
							if v.ViewType == ViewType.Schedule:								
								vp = ScheduleSheetInstance.Create(doc, sht.Id, v.Id, l.ToXyz())
								MoveSchedule(vp)								
								arr.Add([vp,sht])
							elif v.ViewType == ViewType.PanelSchedule:				
								vp = pssi.Create(doc, v.Id, sht)
								vp.Origin = l.ToXyz()
								arr.Add([vp,sht])
							else:
								vp = Viewport.Create(doc, sht.Id, v.Id, l.ToXyz())	
								arr.Add([vp,sht])
						except Exception, e:
							arr.Add([str(e),sht])
				outList.append(arr)								
			else:
				outList.append("Number of views does not match number of locations")				
		OUT = outList
		TransactionManager.Instance.TransactionTaskDone()			
	else:
		OUT = "Number of sheets does not match either the number of view lists of location lists"
else:
	OUT = "Set Run to True"

If the list that’s going into the “SheetList” input of the greyed out codeblock is the same as the list that’s going into the “SheetList” code block, then you are inputting the sheet names and not the actual sheets. That would seem to coincide with the error stating ‘str’ (string) object has no attribute Id.

Gotcha. I’m just giving it a string instead of an actual sheet. I’ll get that taken care of. Thanks