New to Scripting. NEED SOME HELP

So I am more or less trying to figure out why none of the loops I try to create do not work. I am trying to use a for loop to iterate over a list of levels and retrieve the bounding boxes. I plan to then take those bounding boxes and manipulate them to have the dimensions of each level. These bounding boxes will then be used to create Navis Export views per level. I know somebody has probably already done this. But I would like to try and tackle the graph myself. My hurdle is just with trying to get more for loop to work. Here is everything you should need to help me out. Thank you Python Gods!

Keep in mind if I delete the for loop I do get a proper bounding box from the level. But it is 2D. I am going to use data from the bounding box of level in another view to obtain the 3rd dimension.!

Dynamo%20Question|690x404

My best guess, as I cannot see the IN[0], is that either you are trying to loop over one element or it is a nested list and you are looping in the outer level. (But the error points me to believe it is the first case).

Also, what you do inside the loop does not make much sense. For every level you are assigning to the variable bounding a different bounding box, in the end bounding will be the bounding of the last level.
You may want to try this:

boundings = []
for x in assembly:
    bounding = your stuff
    boundings.append(bounding)

it should be:

for x in assembly:
bounding = x.BoundingBox …

x is the item in the list of assembly

1 Like

That’s right! Didn’t pick up that one!

Thanks!

Guys,

Both of those things are exactly what I needed. Attached are the finished product. Thank you Python Pros!

Just realized I did not explain much. So the top left script is the for looped script that corresponds to the top python node. The bottom right is for the bottom python script. Another thing I would like to do is remove the ActiveView and do something that extracts the data from 2 seperate specific views (i.e. north elevation and east elevation) Then I could just combine the 2 lists and get the exact bounding box I would want for each level for my Navis views. But for now I am good with everything you guys did. Most appreciated!

1 Like