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') cmds.setAttr('%s.envelope'%ffd,0) lttc = cmds.ls(his,typ='lattice') lttcTrs = cmds.listRelatives(lttc,p=True,ni=True,pa=True) baseTrs = cmds.listRelatives( cmds.ls(his,typ='baseLattice'),p=True, ni=True, pa=True ) 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,-1) cmds.setAttr('%s.envelope'%ffd,1) cmds.parent( mrrs, w=True ) cmds.makeIdentity( mrrs, t=False, r=False, s=True, n=False, pn=True ) dvs = cmds.lattice(lttc,q=True,dv=True) mrrLttc = cmds.lattice( mrrs, dv=dvs, oc=True ) lttcScl = cmds.getAttr('%s.s'%lttcTrs) baseScl = cmds.getAttr('%s.s'%baseTrs) cmds.setAttr('%s.s'%mrrLttc,*lttcScl) cmds.setAttr('%s.s'%mrrLttc,*baseScl)
Then I try some pymel (where I can’t succeed):
cmds.select(mrrs, r=True) lattice = pm.selected() for point in lattice.pt: latticePointSplit = point.split('.') p1 = pm.pointPosition(point) p2 = pm.pointPosition(point) p3 = pm.pointPosition(point) 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.