Python | TypeError: iteration over non-sequence of type ViewSection


I got the code below from the following link:

# Load the Python Standard and DesignScript Libraries
import clr
import Autodesk
from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and Application
doc = DocumentManager.Instance.CurrentDBDocument

view = UnwrapElement(IN[0])

for v in view:
	if v.CropBoxActive == True:
		csm = v.GetCropRegionShapeManager()

OUT = 0

and its producing the following error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 19, in
TypeError: iteration over non-sequence of type ViewSection

I’m using Revit 2020

I’d be most appreciative if you could assist as to why it is producing an error.

this may happend because you have instance view not a list of view, make this instance as a list
try to use List.Create then Flatten before you input the result to Python node

I actually saw that solution when Googling my error but didn’t think it applied to my solution. Gave it a shot and it seems to have worked!

Thanks a lot @khuzaimah.ElecEng!