[Maya][Python] Get Lattice points positions


I´m trying to get the lattice points positions to recreate a lattice deformer to another object.
I only find to get the position with pm.pointPosition('ffd1Lattice.pt[1][4][1])
Is there a better way to get / query all the positions of the lattice?

Thanks in advice guys!


If you’re using pymel, and it looks like you are. You can iterate over the lattice points directly.

lattice = pm.selected()[0]

for point in lattice.pt:


You can also iterate by getting lattice.pt[0:1][iteration]

I was making a blendshape that would skew each row. And I had code that was a little bit like this:
(If you want each U row, you’ll have to adapt this. I don’t know how to slice in that direction.)

lattice = pm.PyNode('ffd1Lattice')

numberOfRowsS = lattice.sDivisions.get()
numberOfRowsT = lattice.tDivisions.get()

for row in xrange(numberOfRowsT):
    latPoints = lattice.pt[0:numberOfRowsS-1][row]
    pm.move(latPoints, (row, 0, 0), r=True)


Thanks for the responses. Really useful guys!