'List[Object]' has no attribute 'Id'

hi,

I can’t understand this attribute error.

Please Help me…

It is saying that on line 44 where you call either sht.Id or v.Id, either sht or v don’t have the attribute Id. I’d guess one of those inputs are wrong but it is hard to tell when we can’t see anything in the graph or Revit file.

Make sure you aren’t using nested lists as that could be a problem as well. Your node is only accepting a single list, so try flattening all the inputs first and see if it helps.

can you suggest me how to put many views with many sheets using these script??

Can you provide the Dynamo file and a small revit project so we can test it out?

see Attachment below

Assembly views-test - Sample.dyn (39.5 KB)
Assembly views-test - Sample.rvt (2.9 MB)

I don’t have Revit 2018 so I unfortunately cannot open your project and test your script, sorry.

I can only guess what isn’t working in the script. The problem is most likely because of the sheet input. If you are using multiple sheets, your script has to be set up for it. Right now, it cannot process multiple sheets.

Do you want each sheet to get 1 view?

Thank you for advice.
I understand the limitation of software tat you have, but can you help me with script to process multiple sheets.
It would be greatly appreciated.

How are you expecting the graph to work? Do you want one view per sheet? or a list of views per sheet?

4 views per sheet that’s what i am looking for.

Thanks

Can you show me a picture of what your view list and sheet list look like?

i required like this.

I can’t test this so I don’t know if I made any syntax or spelling errors but try this and tell me of any errors:

################### 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 *
################### Definitions ###################
def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]
################### Inputs ###################
#get the bool in port IN[0]...
r = tolist(IN[0])
r = r[0]
#get the sheet in port IN[1] and UnwrapElement if not already...
sht = tolist(UnwrapElement(IN[1]))
#ensure only one sheet is passed (Multiple Sheets not allowed in this example)...
#get the views in port IN[1] and UnwrapElement if not already...
views = tolist(UnwrapElement(IN[2]))
#get the points in port IN[2] (no need to unwrap as these are Dynamo Points)...
locs = tolist(IN[3])

################### Outputs ###################
outList = []

################### Script ###################
if r:
	for s, vws, ls in zip(sht,views,locs):
		if len(vws) == len(ls):
			temp = []
			for v,l in zip(vw, ls):
				TransactionManager.Instance.EnsureInTransaction(doc)
				try:
					if Viewport.CanAddViewToSheet(doc,s.Id,v.Id):
						vp = Viewport.Create(doc,s.Id,v.Id,l.ToXyz())
						outList.append(vp)
				except Exception, e:
					temp.append(e.message)
				TransactionManager.Instance.TransactionTaskDone()
			outList.append(temp)
		else:
			outList.append("Number of Views must match the number of Locations")
	OUT = outList
else:
	OUT = "Set Run to True"

Before the above script can work, the levels of your views elements need to be changed. Right now it is a list of views, within a list, within another list. That is 3 levels. The script only takes 2 levels so you will need to work on flattening it an n amount with list levels.

Hi Robert,

Where is your sheet input? As I see it you are only matching location with number of views.

Please see the error.

Please see image below, sheet input is visible now.

Whoops, in line 42 of the code, change zip(vw,ls): to zip(vws,ls):

I forgot the s in vw there.

it’s again list object error.

Flatten the sheets input before using it.

1 Like

Output is Empty List