[Maya][Python] Get Lattice points positions


#1

Hi!
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!


#2

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:
     print(pm.pointPosition(point))

#3

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)

#4

Thanks for the responses. Really useful guys!