ForLoop Question

Hi, I am green as a goose when it comes to dynamo. The end result that i want is to create views from the levels within my model. What i am trying to do is get the levels from within my model to run through a ForLoop until it has created a view for each level. unfortunately i cannot get it to work & my python skills are 0.
I am hoping someone can point me in the right direction to get this to work, i get that it is wanting an array but i only want it to run through the list & put out the name each time then I will use the name & start looking for levels that correspond with the name & create a view.
I also get that there are scripts out there but i want to learn this & the only way is to do :grinning:

error & screen shot below
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. **
Traceback (most recent call last):
** File “”, line 10, in

TypeError: expected Array[Type], got int

The data you want to work with is assigned to IN[0] by default (subsequent inputs will be IN[1], IN[2]IN[N]). So, you can assign it to a more legible variable name like views.

# Unwrap all views to use them with the Revit API
views = UnwrapElement(IN[0])
names = []

for view in views:

OUT = names

In general, it is best to avoid using list as a variable name as this is reserved for the builtin list object type.

The print statement will also not do anything in the Python node unless you redirect stdout to a file or otherwise a different location.

Thanks for the reply, i was way off, As a side note i found i really don’t need to run a loop as i can just create views from levels using the below.
down the rabbit hole i go :slight_smile:

1 Like