Creating Loop To Select Cvs

i'm trying to select a bunch of cvs using a loop. the print statement i've commented out resolves to what i want, but how do i make that work within the select command?

CODE
for pnts in range ( 0,16 ):
    #print 'wv01_ZZ_XX.cv[',(pnts+2),'][3]'
    cmds.select ( 'wv01_ZZ_XX.cv[(pnts+2)][3]', r=True )

any suggestions?

if it'll help, this creates the plane i'm trying to select points on (so anyone so inclined can test their solution).

CODE
#wv01_01
#makewv01_
cmds.nurbsPlane( n='wv01_ZZ_XX', p=[ 0,0,0 ], ax=[ 0,1,0 ], w=1, lr=1, d=3, u=400, v=1, ch=1 )
cmds.setAttr ( 'wv01_ZZ_XX.scaleX', 200 )
cmds.setAttr ( 'wv01_ZZ_XX.scaleZ', 40 )
cmds.setAttr ( 'wv01_ZZ_XX.rotateX', 90 )
cmds.makeIdentity( 'wv01_ZZ_XX', apply=True, t=1, r=1, s=1, n=0 )

remove replace = True and set add= True instead.

From mayas point of view its faster if you first create the list of what you want to select and select all in one go without updating each loop (as it has some extra overhead, not much but it teaches you not to work on selection in vain)

thanks, but i'll be using this to select a large bunch of cvs and create a cluster, then select another bunch of cvs and create a cluster. i want to select a new group of points each time, hence r=True.

each loop does create one selection that i want

my problem is the syntax for the cv selection. even if i change it to add=True, it still won't work

here's the mel script i'm starting from

CODE
int $pnts = 0;
for ($pnts; $pnts < 16; ++$pnts)
{
select -r wv01_ZZ_XX.cv[($pnts+2)][3] wv01_ZZ_XX.cv[($pnts+18)][3] wv01_ZZ_XX.cv[($pnts+34)][3] wv01_ZZ_XX.cv[($pnts+50)][3] wv01_ZZ_XX.cv[($pnts+66)][3]
wv01_ZZ_XX.cv[($pnts+82)][3] wv01_ZZ_XX.cv[($pnts+98)][3] wv01_ZZ_XX.cv[($pnts+114)][3] wv01_ZZ_XX.cv[($pnts+130)][3] wv01_ZZ_XX.cv[($pnts+146)][3] wv01_ZZ_XX.cv[($pnts+162)][3]
wv01_ZZ_XX.cv[($pnts+178)][3] wv01_ZZ_XX.cv[($pnts+194)][3] wv01_ZZ_XX.cv[($pnts+210)][3] wv01_ZZ_XX.cv[($pnts+226)][3] wv01_ZZ_XX.cv[($pnts+242)][3] wv01_ZZ_XX.cv[($pnts+258)][3]
wv01_ZZ_XX.cv[($pnts+274)][3] wv01_ZZ_XX.cv[($pnts+290)][3] wv01_ZZ_XX.cv[($pnts+306)][3] wv01_ZZ_XX.cv[($pnts+322)][3] wv01_ZZ_XX.cv[($pnts+338)][3] wv01_ZZ_XX.cv[($pnts+354)][3]
wv01_ZZ_XX.cv[($pnts+370)][3] wv01_ZZ_XX.cv[($pnts+386)][3];
newCluster "-n (\"wv01_ZZ_XXcls\" + $pnts)  -envelope 1";
}

all i'm trying to do now is figure out how to do the selection in python. i didn't throw in the cluster bit yet as i want to get selection working first.

figured it out. you have to convert the int to a string.

CODE
for pnts in range ( 0,16 ):
    cmds.select ( "wv01_ZZ_XX.cv[" + str(pnts+2) + "][3]",r=True )

add the cluster command and i've got

CODE
for pnts in range ( 0,16 ):    
    cmds.select ( "wv01_ZZ_XX.cv[" + str(pnts+2) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+18) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+34) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+50) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+66) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+82) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+98) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+114) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+130) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+146) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+162) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+178) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+194) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+210) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+226) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+242) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+258) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+274) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+290) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+306) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+322) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+338) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+354) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+370) + "][3]", "wv01_ZZ_XX.cv[" + str(pnts+386) + "][3]",r=True )
    wv01_ZZ_XX.cv[($pnts+370)][3] wv01_ZZ_XX.cv[($pnts+386)][3];" )
    cmds.cluster ( n="wv01_ZZ_XXcls" + str(pnts),  en=1 )

which works.

Dont make selections, unless your target is to present the selection for the user. Dont try to use scripting like a sledgehammer its ugly and inefficent. If is must say its MUCH more ineffiecent that calling the mel command as a string. (which is your next question)

Instead call:

cmds.cluster ("nurbsSphere1.cv[4][6:7]","nurbsSphere1.cv[5:6][0:7]")