def setupMannequinUI(): """Sets up the side panel UI for the Mannequin plugin.""" currentContext = cmds.currentCtx() influenceObjectsStr = cmds.mannequinContext(currentContext, q=True, io=True) ioTokens = influenceObjectsStr.split(" ") ioDagPaths = ioTokens[::2] ioAvailableStyles = ioTokens[1::2] mannequinDockPtr = MQtUtil.findLayout("mannequinPaletteDock") mannequinDock = wrapInstance(long(mannequinDockPtr), QWidget) mannequinDock.setMinimumWidth(300) mannequinLayoutPtr = MQtUtil.findLayout("mannequinPaletteLayout") mannequinLayout = wrapInstance(long(mannequinLayoutPtr), QWidget) mannequinSearchPtr = MQtUtil.findControl("mannequinSearchField") mannequinSearch = wrapInstance(long(mannequinSearchPtr), QLineEdit) uiFile = QFile(os.path.join(os.path.dirname(__file__), "mannequin.ui")) uiFile.open(QFile.ReadOnly) gui = mannequinToolPanel.loader.load(uiFile, parentWidget=mannequinLayout) uiFile.close() selList = om.MSelectionList() for obj in ioDagPaths: selList.add(obj) joints = [] for i in range(selList.length()): dagPath = selList.getDagPath(i) dependNode = selList.getDependNode(i) styles = ioAvailableStyles[i] joints.append(JointInfo(dagPath, dependNode, styles)) # Alphabetize joints by full DAG path; should sort slightly better. joints = sorted(joints, key=lambda j: j.dagPath.fullPathName()) prefixTrim = commonPrefix(joints) mannequinToolPanel.reset(mannequinLayout, gui, mannequinSearch, prefixTrim) jointDisplays = organizeJoints(joints) for jointDisplay in jointDisplays: mannequinToolPanel.layoutJointGroup(jointDisplay) mannequinToolPanel.finishLayout()
def selectNode(nodeId): currentContext = cmds.currentCtx() # Note: sel is a tuple (nodeName, style). cmds.mannequinContext(currentContext, e=True, sel=nodeId)
def restoreAutoKeyframe(self): currentContext = cmds.currentCtx() cmds.mannequinContext(currentContext, e=True, rak=self.autoKey)
def saveAutoKeyframe(self): currentContext = cmds.currentCtx() self.autoKey = cmds.mannequinContext(currentContext, e=True, sak=True)