How can I find deformed mesh vertices?

How can I find deformed mesh vertices?

Anonymous
Not applicable
920 Views
1 Reply
Message 1 of 2

How can I find deformed mesh vertices?

Anonymous
Not applicable

Hello,

 

I'm new to maya and I'm trying to write a script that creates a lattice deformation and deforms a mesh up until a certain point and then stops. I'm able to query the vertices of my mesh, but not sure how to get the coordinates of the deformed mesh vertices

 

An example of what I'm trying to do:

maya.lattice(model_name, dv=(5, 2, 5), ldv=(5, 2, 5), objectCentered=True)
maya.select('ffd1Lattice.pt[0][0:1][0]')
maya.move(-0.5, 0, 0, relative=True)
maya.select('ffd1Lattice.pt[4][0:1][0]')
maya.move(0.5, 0, 0, relative=True)

children = maya.listRelatives(model_name, allDescendents=True, noIntermediate=True, fullPath=True)

meshes = maya.ls(children, type="mesh")
for mesh in meshes:
     mesh_verts = maya.xform(mesh + '.vtx[*]', ws=True, t=True)

# Not sure how to find this: deformed_verts = maya.xform(*lattice mesh output* + '.vtx[*]', ws=True, t=True)

Could anyone help me find a way to approach this?

 

 

0 Likes
Accepted solutions (1)
921 Views
1 Reply
Reply (1)
Message 2 of 2

tony.su
Autodesk Support
Autodesk Support
Accepted solution

You can try this.

 

import maya.cmds as cmds

cmds.polySphere();
cmds.lattice(dv=(5, 2, 5), ldv=(5, 2, 5), objectCentered=True)

children = cmds.listRelatives("pSphere1", allDescendents=True, noIntermediate=True, fullPath=True)

meshes = cmds.ls(children, type="mesh")
for mesh in meshes:
mesh_verts = cmds.xform(mesh + '.vtx[203]', q=True, ws=True, t=True)
print mesh
print mesh_verts

cmds.select('ffd1Lattice.pt[0][0:1][0]')
cmds.move(-0.5, 0, 0, relative=True)
cmds.select('ffd1Lattice.pt[4][0:1][0]')
cmds.move(0.5, 0, 0, relative=True)


for mesh in meshes:
mesh_verts = cmds.xform(mesh + '.vtx[203]', q=True, ws=True, t=True)
print mesh
print mesh_verts

 

The result as follow:

pSphereShape1
[0.3052126467227936, 0.15643437206745148, -0.9393479228019714]
pSphereShape1Orig
[0.3052126467227936, 0.15643437206745148, -0.9393479228019714]
pSphereShape1
[0.37895670533180237, 0.15643437206745148, -0.9393479228019714]
pSphereShape1Orig
[0.3052126467227936, 0.15643437206745148, -0.9393479228019714]

 

You will find two shapes, pSphereShape1 and pSphereShape1Orig. pSphereShape1 is the shape and pSphereShape1Orig is the original lattice shape. You can get position of deformed shape from pSphereShape1, and get position of original shape from pSphereShape1Orig.



Tony Su
Product Support