# Help with basic levels in Python

**URL:** <https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592>\
**Category:** Uncategorized\
**Created:** [December 17, 2019, 2:16pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592 "2019-12-17T14:16:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saju\_autodesk](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/saju_autodesk/32/61838_2.png) [@saju\_autodesk](https://forum.dynamobim.com/u/saju_autodesk)\
**Post date:** [December 17, 2019, 2:16pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/1 "2019-12-17T14:16:01Z")

</div>

How can make this work in python?

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/d/9d618c4dd0451f8ab2b54748fbc69e73ebd0a170.png)

Actually I am trying to convert my nodes to python script,I am kind of struck here.

here is how my current script looks like.

```
final_points=projected_unique_points_base
final_curves=new_final_curve
#------------------------------------------------------
bounding_box_curve=[]
for i in final_curves:
	bounding_box_curve.append(BoundingBox.ByGeometry(i))

for i in bounding_box_curve:
	for j in final_points:
		result.append(BoundingBox.Contains(i,j))

```

This code gives a flattened list instead of maintaining a list structure,I wanted to ask python to create a new sublist everytime all i are

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 17, 2019, 2:22pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/2 "2019-12-17T14:22:32Z")

</div>

Try indenting the second half under the first. This way all the looping should stay nested together.

---

<div class="post-metadata">

**Author:** ![saju\_autodesk](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/saju_autodesk/32/61838_2.png) [@saju\_autodesk](https://forum.dynamobim.com/u/saju_autodesk)\
**Post date:** [December 17, 2019, 2:26pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/3 "2019-12-17T14:26:43Z")

</div>

like this ?

```
#-----------------------------------------------------
final_points=projected_unique_points_base
final_curves=new_final_curve
#------------------------------------------------------
bounding_box_curve=[]
result=[]
for i in final_curves:
	bounding_box_curve=BoundingBox.ByGeometry(i)
	for j in final_points:
		result.append(BoundingBox.Contains(bounding_box_curve,j))
		
OUT = result

```

Didn’t work though.!  
here is what it returns vs what I wanted.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/1/31338327a071cd462ba163d89e9c4d12f9169497.png)

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [December 17, 2019, 2:56pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/4 "2019-12-17T14:56:01Z")

</div>

Maybe something like that :

```
result=[]
for i in final_curves:
	bounding_box_curve=BoundingBox.ByGeometry(i)
	curves=[]
	for j in final_points:
		curves.append(BoundingBox.Contains(bounding_box_curve,j))
	result.append(curves)
		
OUT = result
```

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [December 17, 2019, 3:03pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/5 "2019-12-17T15:03:18Z")

</div>

You can also put it inside a `Custom Node` to leverage **List@Levels** 🙂

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [December 17, 2019, 3:18pm UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/6 "2019-12-17T15:18:43Z")

</div>

It looks like it’s just a list structure issue? In which case I think you need another list to append to.  
It would look something like this:

```
primary_list = []
for a in b:
    secondary_list = []
    for c in d:
        secondary_list.append(your_output_here)
    primary_list.append(secondary_list)
out = primary_list
```

---

<div class="post-metadata">

**Author:** ![saju\_autodesk](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/saju_autodesk/32/61838_2.png) [@saju\_autodesk](https://forum.dynamobim.com/u/saju_autodesk)\
**Post date:** [December 18, 2019, 10:10am UTC](https://forum.dynamobim.com/t/help-with-basic-levels-in-python/44592/7 "2019-12-18T10:10:42Z")

</div>

This gives a correct list structure but, the count of each sublist is equal to count of final\_points but I am looking at sublist count = final\_curves count.
