Dynamo用python 奇偶拆分list

方法一:

 1 import clr
 2 clr.AddReference('ProtoGeometry')
 3 from Autodesk.DesignScript.Geometry import *
 4 
 5 
 6 dataEnteringNode = IN
 7 start = IN[0]
 8 end = IN[1]
 9 step = IN[2]
10 count = range(int(start),int(end),int(step))
11 list_a = []
12 list_b = []
13 for i in count:
14     lem_a = count.index(i)
15     if (lem_a%2) == 0:
16         list_a.append(i)
17         lem_a = lem_a + 1
18     else:
19         list_b.append(i)
20         lem_a = lem_a + 1
21 
22 OUT = count, list_a, list_b

方法二:

 1 import clr
 2 clr.AddReference('ProtoGeometry')
 3 from Autodesk.DesignScript.Geometry import *
 4 
 5 
 6 dataEnteringNode = IN
 7 start = IN[0]
 8 end = IN[1]
 9 step = IN[2]
10 count = range(int(start),int(end),int(step))
11 list_a = count[::2]
12 list_b = count[1::2]
13 OUT = count, list_a, list_b

 

posted @ 2018-11-29 15:42  AnnLT  阅读(437)  评论(0)    收藏  举报