def fixOrientation(jnt): name = jnt.name() sName = name.split("_") ctlName = "_".join(sName[:-1]) + "_control" offName = "_".join(sName[:-1]) + "_offgrp" oOff = pym.PyNode(offName) oCtl = pym.PyNode(ctlName) oParent = oOff.getParent() world = False if not oParent: world = True children = oCtl.getChildren(type="transform") if not world: print oParent.name() else: print "world" print children pym.parent(oCtl, w=1, a=1) pym.parent(oOff, w=1, a=1) oTM.copyTM(jnt, oOff) pym.parent(oCtl, oOff, a=1) pym.makeIdentity(oCtl, apply=True, translate=True, rotate=True, scale=True) if not world: pym.parent(oOff, oParent, a=1) for child in children: pym.parent(child, oCtl, a=1)
def createFKControlChain(start, end=None, p="world", control="control", ctltype="transform"): head = "_".join(start.name().split("_")[:-1]) name = "{0}_{1}".format(head, "offgrp") ctlname = "{0}_fk_{1}".format(head, control) node = pym.createNode("transform", n=name) # pym.parent(node, start, r=True) copyTM(start, node) if p == "world": pym.parent(node, w=True, a=True) else: pym.parent(node, p, a=True) if ctltype == "transform": ctl = pym.createNode(ctltype, n=ctlname, p=node) else: ctl = pym.createNode(ctltype, n=ctlname + "_shape") ctltm = ctl.getParent() ctltm.rename(ctlname) pym.parent(ctltm, node, r=True) if start != end: for child in start.getChildren(type="transform"): if end is None or child in fromTo(start, end): createFKControlChain(child, end, p=ctl.name(), control=control, ctltype=ctltype)
def fixScale(root, p=None): newJnt = pym.createNode("joint", n=root.name() + "_fix") copyTM(root, newJnt) pym.makeIdentity(newJnt, apply=True, translate=True, rotate=True, scale=True) if p: pym.parent(newJnt, p) for child in root.getChildren(type="joint"): fixScale(child, p=newJnt)
def createDef(root, p=None): nf = root.name() newname = nf.replace("_ll_", "_l_") newJnt = pym.createNode("joint", n=newname) copyTM(root, newJnt) pym.makeIdentity(newJnt, apply=True, translate=True, rotate=True, scale=True) if p: pym.parent(newJnt, p) for child in root.getChildren(type="joint"): createDef(child, p=newJnt)
def recurse(root, p=None): nf = root.name() newname = nf.replace(aux, tgt) newJnt = pym.createNode("joint", n=newname) copyTM(root, newJnt) newJnt.radius.set(root.radius.get()) pym.makeIdentity(newJnt, apply=True, translate=True, rotate=True, scale=True) if p: pym.parent(newJnt, p) for child in root.getChildren(type="joint"): recurse(child, p=newJnt)
### Align Controls import MEm.chan.srt as srt reload(srt) import MEm.xform.obj as oXF reload(oXF) csrt = srt.srt for ofg in pym.ls(sl=1, dag=1): if ofg.name().endswith("_offgrp"): jntref = ofg.name().rsplit("_", 1)[0] + "_def" try: jnt = pym.PyNode(jntref) except: jnt = None if jnt is not None: print "match", ofg.name(), " with", jntref csrt.lockAttrs(ofg, False) csrt.keyAttrs(ofg, True) prnt = ofg.getParent() pym.parent(ofg, w=1, a=1) oXF.copyTM(jnt, ofg) pym.parent(ofg, prnt, a=1) csrt.lockAttrs(ofg, True) csrt.keyAttrs(ofg, False)