Home > Mobile >  Maya Python select each time next listed object
Maya Python select each time next listed object

Time:08-16

I am looking for a way to select each time a different object contained in a list, so if my list contains [pCube1, pCube2, pCube3]. The first time it select the first element (pCube1), than the second (pCube2) ecc. Do you think is possible with Python?

CodePudding user response:

Have you just tried a for loop?

l = [pCube1, pCube2, pCube3]
n = len(l) - 1

for i in range(0, n):
    current_element = l[i]
    do_something(current_element)

CodePudding user response:

You may be looking for an iterator

x = iter([1,2,3])
next(x) # 1
next(x) # 2
next(x) # 3
next(x) # will throw an exception
  • Related