Slice in revit python editor

Howdy All,

I am attempting to slice a list in python. I have achieved what I want in revit python shell.
image
But when I transfer the code to revit. It throws an error saying exp int, got slice. Does revit python editor not interpret the code the same way?

import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

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

doc = DocumentManager.Instance.CurrentDBDocument

part = UnwrapElement(IN[0])
cnt = UnwrapElement(IN[1])

lst = [part]

for i in lst:
    num = i[(cnt - cnt)::(cnt)]
    num1 = i[((cnt + 1) - cnt)::(cnt)]
    num2 = i[((cnt + 2) - cnt)::(cnt)]
    num3 = i[((cnt + 3) - cnt)::(cnt)]
    num4 = i[((cnt + 4) - cnt)::(cnt)]

OUT =  num

Have you cleaned your input?

step=10
lst=range(0,101,step)

num1=[i+0 for i in lst]
num2=[i+1 for i in lst]
num3=[i+2 for i in lst]
num4=[i+3 for i in lst]

OUT = [num1,num2,num3,num4]

Please post your graph.

@coastguard09 ??

4 Likes

Sorry for the late response. I was able to use a combination of slice and chop nodes to get the desired results after I realized that I did not need all of those items from the list.

However, for the sake of knowledge, I did attempt what @til.shviger suggested in his second post. It worked beautifully and I thank you for the reply.