Expected View, got List[object] ? New in Python, please help!

Hello everyone, I’m a total beginner when it comes to Python and struggling tremendously to replicate the Turn On Top & Left Grid Bubbles Only. In my case I want the Python node to work with multiple views (List), but when I try to do so I get the following error:

Python Code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices

from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

g = UnwrapElement(IN[0])
b = UnwrapElement(IN[1])
v = UnwrapElement(IN[2])

TransactionManager.Instance.EnsureInTransaction(doc)

for g, b in zip(g, b):
	if b:
		g.ShowBubbleInView(DatumEnds.End1,v)
		g.HideBubbleInView(DatumEnds.End0,v)
	else:
		g.ShowBubbleInView(DatumEnds.End0,v)
		g.HideBubbleInView(DatumEnds.End1,v)
	
TransactionManager.Instance.TransactionTaskDone()

doc.Regenerate()

OUT = g

Any idea how to solve this issue?

Thanks in Advance.

This is pretty common when converting a code for a single object to one expecting a list. Do some searching in the forums for handling lists in python and you should find some good resources. You just need to loop for each item in your list now.

1 Like

Thanks for replying. I tried a few methods I found in the forum but nothing seems to work, I still don’t understand 100% how a loop work in this particular scenario. Can you point me in the right direction? Thanks in advance!

Can you show us what you found and what you tried?