[Maya Python] Mirroring lattice ( problem with lattice points )

python
maya

#1

Hello, everybody. I am looking for some help in scripting - rigging. I want to make tool which will mirror Lattice.
I start with duplicating ,putting in group and putting scale x -1 and etc. Here is some code example to understand faster:

geo = 'pSphere1'

his = cmds.listHistory( geo )
ffd = cmds.ls(his,typ='ffd')[0]
cmds.setAttr('%s.envelope'%ffd,0)

lttc = cmds.ls(his,typ='lattice')[0]
lttcTrs = cmds.listRelatives(lttc,p=True,ni=True,pa=True)[0]
baseTrs = cmds.listRelatives( cmds.ls(his,typ='baseLattice')[0],p=True, ni=True, pa=True )[0]
gp = cmds.createNode('transform')
cmds.parent(geo,lttcTrs,baseTrs,gp)

mrrs = cmds.duplicate(gp,n='%s_mirror'%gp,rc=True)
cmds.setAttr('%s.sx'%mrrs[0],-1)
cmds.setAttr('%s.envelope'%ffd,1)

cmds.parent( mrrs[1], w=True )
cmds.makeIdentity( mrrs[1], t=False, r=False, s=True, n=False, pn=True )

dvs = cmds.lattice(lttc,q=True,dv=True)
mrrLttc = cmds.lattice( mrrs[1], dv=dvs, oc=True )
lttcScl = cmds.getAttr('%s.s'%lttcTrs)[0]
baseScl = cmds.getAttr('%s.s'%baseTrs)[0]
cmds.setAttr('%s.s'%mrrLttc[1],*lttcScl)
cmds.setAttr('%s.s'%mrrLttc[2],*baseScl) 

Then I try some pymel (where I can’t succeed):

cmds.select(mrrs[2], r=True)
lattice = pm.selected()[0]

for point in lattice.pt:
    latticePointSplit = point.split('.')
    p1 = pm.pointPosition(point)[0]
    p2 = pm.pointPosition(point)[1]
    p3 = pm.pointPosition(point)[2]
    pm.move(mrrLttc+'Shape', (p1, p2, p3) , r=True)

What is left to do here , snapping newly made lattice point to old one. I can’t do it with now , because number of lattice point is different on those lattices, since old one was scaled -1 , that points are reversed. So I would be really grateful if somebody can give me idea , how to snap that newly made lattice points to old one.

Best regards,
Vlad


#2

I’m not totally clear on what you want – do you need to reproduce the original lattice while removing the -1 scale?