Pymel/Cmds, select a vertex, edge or lattice point by index number


Gentlemen, my ladies,
I am doing a little bit of modeling with python, but yet have to see once how to select components like uvs, vertices, etc. How do you access those arrays.

I seen tons about selection filters sm=31, selectType… but never in the elegant exemples do you ever see an actual selection by index number.

In this script, after creating a lattice, I would like to apply this selection:
select -cl ;
select -r[1][0:1][0][1][0:1][1] ;

the lattice points i want to move.
thanks guys!

import pymel.core as pmc

firstBlockLenght = 1.0637
sectionLenght = 0.2602
midSectionLenght = 2.7884

railLenght = 11.000

spans = int((railLenght - ((firstBlockLenght * 2)+ midSectionLenght))/(sectionLenght 2))
differenceLenght = railLenght -((firstBlockLenght * 2) + midSectionLenght)-(spans
upperDiffLenght = (differenceLenght - (sectionLenght 2))-1

railPieces = list()
for x in range(spans):
mike = pmc.duplicate(“section”, name = “section_” + str(x))
pmc.move((firstBlockLenght + (x*sectionLenght)),0,0,mike,r=True)
pmc.lattice(dv=(2,2,2), oc=True)
if(differenceLenght !=0):
if(upperDiffLenght < differenceLenght):
(part where i move to lattice points to fit a gap between pieces)

pmc.lattice(dv=(2,2,2), oc=True)
selection = mel.eval(“select -r[1][0:1][0][1][0:1][1]”)

if(differenceLenght !=0):
if(upperDiffLenght < differenceLenght):
pmc.move(-upperDiffLenght,0,0, selection, r=True)
pmc.move(differenceLenght,0,0, selection, r=True)

perhaps something more pythonic and direct? :christmas_tree:

#3‘[1][1][1]’, r=True)‘[1][1][0]’, add=True)‘[1][0][0]’, add=True)‘[1][0][1]’, add=True)

this worked, wow


pmc.polyUnite(muv=True, op=True, ch=False, name = ‘legoRail’)“railBlocks”,add=True)
v = pmc.polyEvaluate(‘legoRail’, v=True)
vertexString = ‘legoRail.vtx[0:’+str(v - 1)+’]'
pmc.polyMergeVertex(d=0.001, am =True, ch=False)



railLenght = 11 <— no
railLenght = float(11) <— yes



pretty coo! so I can get any size rails over 5 units long
takes about a second to run