# Python - Cant get items from list

**URL:** <https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111>\
**Category:** Uncategorized\
**Tags:** python\
**Created:** [March 6, 2017, 3:48pm UTC](https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111 "2017-03-06T15:48:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin.Bell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kevin.bell/32/22476_2.png) [@Kevin.Bell](https://forum.dynamobim.com/u/Kevin.Bell)\
**Post date:** [March 6, 2017, 3:48pm UTC](https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111/1 "2017-03-06T15:48:45Z")

</div>

Hi,

I’m attempting to write some Python code which modifies the crop region o f an elevation using the ViewCropRegionShapeManager Class.

I’ve set up Dynamo using the Select View node which passes the result to a Python script:

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/f/bf1f5511f3faf36db8c0549fab2cfdb8c20d2ef2.JPG)

The script extracts the CropRegion (note its runs in Revit 2017), and returns a list of the 4 lines making up the crop:

```
# Dynamo
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

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

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
elefound = UnwrapElement(IN[0])	# An element - should be an elevation

#Get CropRegionShapeManager from elevation
elecrsm = elefound.GetCropRegionShapeManager()

#Get Crop Region shape
crshape = elecrsm.GetCropShape()

#Assign your output to the OUT variable.
OUT = [crshape]

```

This gives the view boundary lines (in a list for some reason):

0 List  
…0 List  
…0 Autodesk.Revit.DB.Line  
…1 Autodesk.Revit.DB.Line  
…2 Autodesk.Revit.DB.Line  
…3 Autodesk.Revit.DB.Line

The problem I have is that I now want to extract the start and endpoint of the lines, but when I try to take one of the lines from the list I get an indexing error:

_Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed._  
_Traceback (most recent call last):_  
_File “”, line 40, in_   
_TypeError: ‘CurveLoop’ object is unsubscriptable_

Am I missing something? I think the problem is that the list is an Ilist, not a list, but I see no reason why I cannot extract items from it?

Thanks

---

<div class="post-metadata">

**Author:** ![T\_Pover](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/t_pover/32/19147_2.png) [@T\_Pover](https://forum.dynamobim.com/u/T_Pover)\
**Post date:** [March 6, 2017, 8:31pm UTC](https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111/2 "2017-03-06T20:31:36Z")

</div>

I believe you can’t directly index into a Curveloop, but what you can do is iterate over it with a for loop like this:  
for curve in curveloop:

and then do with the lines whatever you want.

---

<div class="post-metadata">

**Author:** ![Kevin.Bell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kevin.bell/32/22476_2.png) [@Kevin.Bell](https://forum.dynamobim.com/u/Kevin.Bell)\
**Post date:** [March 8, 2017, 11:35am UTC](https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111/3 "2017-03-08T11:35:30Z")

</div>

OK, thanks, I’ll try that.

What I don’t understand is why the CurveLoop appears like a list in a watch node:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/8/3/830db3eeaf07981c4170b510a601c78c4a540f57.png)

---

<div class="post-metadata">

**Author:** ![Einar\_Raknes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/einar_raknes/32/8566_2.png) [@Einar\_Raknes](https://forum.dynamobim.com/u/Einar_Raknes)\
**Post date:** [March 8, 2017, 2:01pm UTC](https://forum.dynamobim.com/t/python-cant-get-items-from-list/10111/4 "2017-03-08T14:01:47Z")

</div>

Remove the [] from OUT = [crshape]
