Script to select every nth object ?

Script to select every nth object ?

SmokeyBear
Contributor Contributor
2,206 Views
2 Replies
Message 1 of 3

Script to select every nth object ?

SmokeyBear
Contributor
Contributor

 MEL/Python Newbie here.   Could someone provide me with a MEL script (or Python script) to Select every nth object in a scene, or from a group of objects in a scene?

 

Thank you, in advance!

Respectfully,

Forester

0 Likes
Accepted solutions (2)
2,207 Views
2 Replies
Replies (2)
Message 2 of 3

haggi_master
Advocate
Advocate
Accepted solution

To select every 4th object in the scene try this (pymel can be exchanged by maya.cmds if you like):

import pymel.core as pm
allObjects = pm.ls(geometry=True)
selectList = []
nth = 4
for i in range(0, len(allObjects), nth):
    selectList.append(allObjects[i])
pm.select(selectList)
Message 3 of 3

SmokeyBear
Contributor
Contributor
Accepted solution

Thank you very, very much. I really appreciate this. You're great!

0 Likes