def selectionChanged(self): """ I need to add a check in case no selection exists""" selection = cmds.ls(selection=True, transforms=True) if len(selection) > 0: selectedNode = selection[0] characterNamespaceInfo = utils.stripLeadingNamespace(selectedNode) if characterNamespaceInfo != None and characterNamespaceInfo[0] == self.selectedCharacter: blueprintNamespaceInfo = utils.stripLeadingNamespace(characterNamespaceInfo[1]) if blueprintNamespaceInfo != None: listEntry = blueprintNamespaceInfo[0].partition("__")[2] allEntries = cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], q=True, allItems=True) if listEntry in allEntries: cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], edit=True, selectItem=listEntry) if listEntry != self.previousBlueprintListEntry: self.refreshAnimationModuleList() moduleNamespaceInfo = utils.stripLeadingNamespace(blueprintNamespaceInfo[1]) if moduleNamespaceInfo != None: allEntries = cmds.textScrollList(self.UIElements["animationModule_textScroll"], q=True, allItems=True) if moduleNamespaceInfo[0] in allEntries: cmds.textScrollList(self.UIElements["animationModule_textScroll"], edit=True, selectItem=moduleNamespaceInfo[0]) self.setupModuleSpecificControls() self.setupSpaceSwitchingControls()
def createUserInterface(self, blueprintModule): self.currentBlueprintModule = blueprintModule characterNamespaceInfo = utils.stripLeadingNamespace(blueprintModule) characterNamespace = characterNamespaceInfo[0] blueprintModuleNamespace = characterNamespaceInfo[1] characterName = characterNamespace.partition("__")[2] blueprintModuleInfo = blueprintModuleNamespace.partition("__") blueprintModuleName = blueprintModuleInfo[0] blueprintModuleUserSpecifiedName = blueprintModuleInfo[2] windowWidth = 600 windowHeight = 200 self.UIElements["window"] = cmds.window( "modMaintain_UI_window", width=windowWidth, height=windowHeight, title="Module maintenance for " + characterName + ":" + blueprintModuleUserSpecifiedName, sizeable=False) self.UIElements["topRowLayout"] = cmds.rowLayout( nc=2, columnWidth2=(296, 296), columnAttach2=("both", "both"), columnOffset2=(10, 10), rowAttach=([1, "both", 5], [2, "both", 5])) self.UIElements["controlModule_textScrollList"] = cmds.textScrollList( sc=self.UI_controlModuleSelected) for controlModule in self.controlModuleCompatibility: if blueprintModuleName in controlModule[2]: if not self.isModuleInstalled(controlModule[1]): cmds.textScrollList( self.UIElements["controlModule_textScrollList"], edit=True, append=controlModule[1]) self.UIElements["right_columnLayout"] = cmds.columnLayout(adj=True, rs=3) self.UIElements["nameText"] = cmds.text( label="No Animation Modules to Install") self.UIElements["descriptionScrollField"] = cmds.scrollField( wordWrap=True, height=110, editable=False, text="") cmds.separator() self.UIElements["installBtn"] = cmds.button(enable=False, label="Install") if cmds.textScrollList(self.UIElements["controlModule_textScrollList"], q=True, numberOfItems=True) != 0: cmds.textScrollList( self.UIElements["controlModule_textScrollList"], edit=True, selectIndexedItem=1) self.UI_controlModuleSelected() cmds.showWindow(self.UIElements["window"])
def createSingleOrientationControlAtJoint(self,joint): controlFile = os.environ['RIGGING_TOOL_ROOT'] + '/ControlObjects/Blueprint/singleJointOrientation_control.ma' cmds.file(controlFile, i=True) container = cmds.rename('singleJointOrientation_control_container', joint + '_singleJointOrientation_control_container') utils.addNodeToContainer(self.containerName, container) for node in cmds.container(container, q=True, nodeList=True): cmds.rename(node, joint + '_' + node, ignoreShape=True) control = joint + '_singleJointOrientation_control' cmds.parent(control, self.moduleTransform, absolute=True) translationControl = self.getTranslationControl(joint) pointConstraint = cmds.pointConstraint(translationControl, control, maintainOffset=False, n=control + '_pointConstraint')[0] utils.addNodeToContainer(self.containerName, pointConstraint) jointOrient = cmds.xform(joint, q=True, worldSpace=True, rotation=True) cmds.xform(control, worldSpace=True, absolute=True, rotation=jointOrient) jointNameWithoutNamespace = utils.stripLeadingNamespace(joint)[1] attrName = jointNameWithoutNamespace + '_R' cmds.container(container, edit=True, publishAndBind=[control+'.rotate', attrName]) cmds.container(self.containerName, edit=True, publishAndBind=[container + '.' + attrName, attrName]) return control
def rehook(self, newHookObject): oldHookObject = self.findHookObject() self.hookObject = (self.moduleNamespace + ':unhookedTarget') if newHookObject != None: if newHookObject.find('_translation_control') != -1: splitString = newHookObject.split('_translation_control') if splitString[1] == '': if utils.stripLeadingNamespace(newHookObject)[0] != self.moduleNamespace: self.hookObject = newHookObject if self.hookObject == oldHookObject: return self.unconstrainRootFromHook() cmds.lockNode(self.containerName, lock=False, lockUnpublished=False) hookConstraint = (self.moduleNamespace + ':hook_pointConstraint') cmds.connectAttr((self.hookObject + '.parentMatrix[0]'), (hookConstraint + '.target[0].targetParentMatrix'), force=True) cmds.connectAttr((self.hookObject + '.translate'), (hookConstraint + '.target[0].targetTranslate'), force=True) cmds.connectAttr((self.hookObject + '.rotatePivot'), (hookConstraint + '.target[0].targetRotatePivot'), force=True) cmds.connectAttr((self.hookObject + '.rotatePivotTranslate'), (hookConstraint + '.target[0].targetRotateTranslate'), force=True) cmds.lockNode(self.containerName, lock=True, lockUnpublished=True)
def installDuplicate(self,duplicatePath, selection, *args): cmds.file(duplicatePath, i=True, namespace='TEMPLATE_1') moduleNames = self.resolveNamespaceClashes('TEMPLATE_1') groupNames = self.resolveGroupNameClashes('TEMPLATE_1') groups = [] for name in groupNames: groups.append(name[1]) if len(groups) > 0: sceneGroupContainer = 'Group_container' cmds.lockNode(sceneGroupContainer, lock=False, lockUnpublished=False) utils.addNodeToContainer(sceneGroupContainer, groups, includeShapes=True, force=True) for group in groups: groupNiceName = group.partition('__')[2] cmds.container(sceneGroupContainer, edit=True, publishAndBind=[group+'.translate',groupNiceName+'_t']) cmds.container(sceneGroupContainer, edit=True, publishAndBind=[group+'.rotate',groupNiceName+'_r']) cmds.container(sceneGroupContainer, edit=True, publishAndBind=[group+'.globalScale',groupNiceName+'_globalScale']) cmds.lockNode(sceneGroupContainer, lock=True, lockUnpublished=True) cmds.namespace(setNamespace=':') cmds.namespace(moveNamespace=('TEMPLATE_1',':'),force=True) cmds.namespace(removeNamespace='TEMPLATE_1') newSelection = [] for node in selection: found = False for group in groupNames: oldName = group[0].partition('TEMPLATE_1:')[2] newName = group[1] if node == oldName: newSelection.append(newName) found = True break if not found: nodeNamespaceInfo = utils.stripLeadingNamespace(node) if nodeNamespaceInfo != None: nodeNamespace = nodeNamespaceInfo[0] nodeName = nodeNamespaceInfo[1] searchName = 'TEMPLATE_1:' + nodeNamespace for module in moduleNames: if module[0] == searchName: newSelection.append(module[1] + ':' + nodeName) if len(newSelection) > 0: cmds.select(newSelection, replace=True)
def installDuplicate(self, duplicatePath, selection, *args): cmds.file(duplicatePath, i=True, namespace="TEMPLATE_1") moduleNames = self.resolveNamespaceClashes("TEMPLATE_1") groupNames = self.resolveGroupNameClashes("TEMPLATE_1") groups = [] for name in groupNames: groups.append(name[1]) if len(groups) > 0: sceneGroupContainer = "Group_container" cmds.lockNode(sceneGroupContainer, lock=False, lockUnpublished=False) utils.addNodeToContainer(sceneGroupContainer, groups, includeShapes=True, force=True) for group in groups: groupNiceName = group.partition("__")[2] cmds.container(sceneGroupContainer, edit=True, publishAndBind = [group+".translate", groupNiceName+"_t"]) cmds.container(sceneGroupContainer, edit=True, publishAndBind = [group+".rotate", groupNiceName+"_r"]) cmds.container(sceneGroupContainer, edit=True, publishAndBind = [group+".globalScale", groupNiceName+"_globalScale"]) cmds.lockNode(setNamespace=":") cmds.namespace(moveNamespace=("TEMPLATE_1", ":"), force=True) cmds.namespace(removeNamespace="TEMPLATE_1") newSelection = [] for node in selection: found = False for group in groupNames: oldName = group[0].partition("TEMPLATE_1:")[2] newName = group[1] if node == oldName: newSelection.append(newName) found = True break if not found: nodeNamespaceInfo = utils.stripLeadingNamespace(node) if nodeNamespaceInfo != None: nodeNamespace = nodeNamespaceInfo[0] nodeName = nodeNamespaceInfo[1] searchName = "TEMPLATE_1:" +nodeNamespace for module in moduleNames: if module[0] == searchName: newSelection.append(module[1] + ":" +nodeName) if len(newSelection) > 0: cmds.select(newSelection, replace=True)
def findChildModules(self, group): modules = [] children = cmds.listRelatives(group, children=True) if children != None: for child in children: moduleNamespaceInfo = utils.stripLeadingNamespace(child) if moduleNamespaceInfo != None: modules.append(moduleNamespaceInfo[0]) elif child.find("Group__") != 1: modules.extend(self.findChildModules(child)) return modules
def publishNameToModuleContainer(self, attribute, attributeNiceName, publishToOuterContainers=True): if self.moduleContainer == None: return blueprintName = utils.stripLeadingNamespace(self.blueprintNamespace)[1].partition("__")[2] attributePrefix = blueprintName + "_" + self.moduleNamespace + "_" publishedName = attributePrefix + attributeNiceName if publishToOuterContainers: self.publishedNames.append(publishedName) cmds.container(self.moduleContainer, edit=True, publishAndBind=[attribute, publishedName])
def UI(self, parentLayout): cmds.setParent(parentLayout) cmds.separator() niceName = utils.stripLeadingNamespace(self.controlObject)[1] cmds.text(label=niceName) cmds.attrControlGrp(attribute=self.controlObject + ".display", label="Visibility: ") if self.translation == [True, True, True]: cmds.attrControlGrp(attribute=self.controlObject + ".translate", label="Translate") else: if self.translation[0] == True: cmds.attrControlGrp(attribute=self.controlObject + ".translateX", label="Translate X") if self.translation[1] == True: cmds.attrControlGrp(attribute=self.controlObject + ".translateY", label="Translate Y") if self.translation[2] == True: cmds.attrControlGrp(attribute=self.controlObject + ".translateZ", label="Translate Z") if self.rotation == [True, True, True]: cmds.attrControlGrp(attribute=self.controlObject + ".rotate", label="Rotate") else: if self.translation[0] == True: cmds.attrControlGrp(attribute=self.controlObject + ".rotateX", label="Rotate X") if self.translation[1] == True: cmds.attrControlGrp(attribute=self.controlObject + ".rotateY", label="Rotate Y") if self.translation[2] == True: cmds.attrControlGrp(attribute=self.controlObject + ".rotateZ", label="Rotate Z") # WARNING Commented out the global scale here. if self.globalScale == True: try: cmds.attrControlGrp(attribute=self.controlObject + ".globalScale", label="Scale") except: pass
def publishNameToModuleContainer(self, attribute, attributeNiceName, publishToOuterContainers=True): if self.moduleContainer == None: return blueprintName = utils.stripLeadingNamespace(self.blueprintNamespace)[1].partition("__")[2] attributePrefix = blueprintName + "_" + self.moduleNamespace + "_" publishedName = attributePrefix + attributeNiceName if publishToOuterContainers: self.publishedNames.append(publishedName) cmds.container(self.moduleContainer, edit = True, publishAndBind=[attribute, publishedName])
def resolveNameChangeMirrorLinks(self,names, tempNamespace): moduleNamespaces = False firstOldNode = names[0][0] if utils.stripLeadingNamespace(firstOldNode)[1].find('Group__') == -1: moduleNamespaces = True for n in names: oldNode = n[0] if moduleNamespaces: oldNode += ':module_grp' if cmds.attributeQuery('mirrorLinks', n=oldNode, exists=True): mirrorLink = cmds.getAttr(oldNode + '.mirrorLinks') mirrorLinkInfo = mirrorLink.rpartition('__') mirrorNode = mirrorLinkInfo[0] mirrorAxis = mirrorLinkInfo[2] found = False container = '' if moduleNamespaces: oldNodeNamespace = n[0] container = oldNodeNamespace + ':module_container' else: container = tempNamespace + ':Group_container' for nm in names: oldLink = nm[0].partition(tempNamespace + ':')[2] if oldLink == mirrorNode: newLink = nm[1] if cmds.objExists(container): cmds.lockNode(container, lock=False, lockUnpublished=False) cmds.setAttr(oldNode + '.mirrorLinks', newLink+'__'+mirrorAxis, type='string') if cmds.objExists(container): cmds.lockNode(container, lock=True, lockUnpublished=True) found = True break if not found: if cmds.objExists(container): cmds.lockNode(container, lock=False, lockUnpublished=False) cmds.deleteAttr(oldNode,at='mirrorLinks') if cmds.objExists(container): cmds.lockNode(container, lock=True, lockUnpublished=True)
def resolveNameChangeMirrorLinks(self, names, tempNamespace): moduleNamespaces = False firstOldNode = names[0][0] if utils.stripLeadingNamespace(firstOldNode)[1].find("Group__") == -1: moduleNamespaces = True for n in names: oldNode = n[0] if moduleNamespaces: oldNode += ":module_grp" if cmds.attributeQuery("mirrorLinks", n=oldNode, exists=True): mirrorLinks = cmds.getAttr(oldNode+".mirrorLinks") mirrorLinkInfo = mirrorLink.rpartition("__") mirrorNode = mirrorLinkInfo[0] mirrorAxis = mirrorLinkInfo[2] found = False container = "" if moduleNamespaces: oldNodeNamespace = n[0] container = oldNamespace + ":module_container" else: container = tempNamespace + ":Group_container" for nm in names: oldLink = nm[0].partition(tempNamespace+":")[2] if oldLink == mirrorNode: newLink = nm[1] if cmds.objExists(container): cmds.lockNode(container, lock=False, lockUnpublished=False) cmds.setAttr(oldNode+".mirrorLinks", newLink+"__"+mirrrorAxis, type="string") if cmds.objExists(container): cmds.lockNode(container, lock=True, lockUnpublished=True) found = True break if not found: if cmds.objExists(container): cmds.lockNode(container, lock=False, lockUnpublished=False) cmds.deleteAttr(oldNode, at="mirrorLinks") if cmds.objExists(container): cmds.lockNode(container, lock=True, lockUnpublished=True)
def findSelectedCharacter(self): selection = cmds.ls(selection=True, transforms=True) character = None if len(selection) > 0: selected = selection[0] selectedNamespaceInfo = utils.stripLeadingNamespace(selected) if selectedNamespaceInfo != None: selectedNamespace = selectedNamespaceInfo[0] if selectedNamespace.find("Character__") == 0: character = selectedNamespace return character
def attributeChange_callBackMethod(self, object, attribute, *args): if cmds.checkBox(self.blueprint_UI_instance.UIElements['symmetryMoveCheckBox'],q=True, value=True): moduleInfo = utils.stripLeadingNamespace(object) module = moduleInfo[0] objectName = moduleInfo[1] moduleGroup = module + ':module_grp' if cmds.attributeQuery('mirrorLinks', n=moduleGroup, exists=True): mirrorLinks = cmds.getAttr(moduleGroup + '.mirrorLinks') mirrorModule = mirrorLinks.rpartition('__')[0] newValue = cmds.getAttr(object+attribute) mirrorObj = mirrorModule + ':' + objectName cmds.setAttr(mirrorObj + attribute, newValue)
def duplicateModule_processGroup(self, group): returnModules = [] children = cmds.listRelatives(group, children=True, type='transform') for c in children: selectionNamespaceInfo = utils.stripLeadingNamespace(c) if selectionNamespaceInfo != None: returnModules.append(selectionNamespaceInfo[0]) else: if c.find('Group__') == 0: returnModules.extend(self.duplicateModule_processGroup(c)) return returnModules
def findSelectedCharacter(self): selection = cmds.ls(selection=True, transforms=True) character = None if len(selection) > 0: selected = selection[0] selectedNamespaceInfo = utils.stripLeadingNamespace(selected) if selectedNamespaceInfo != None: selectedNamespace = selectedNamespaceInfo[0] if selectedNamespace.find('Character__') == 0: character = selectedNamespace return character
def __init__(self,moduleNamespace): self.moduleContainer = None if moduleNamespace == None: return moduleNamespaceInfo = utils.stripAllNamespaces(moduleNamespace) self.blueprintNamespace = moduleNamespaceInfo[0] self.moduleNamespace = moduleNamespaceInfo[1] self.characterNamespaceOnly = utils.stripLeadingNamespace(self.blueprintNamespace)[0] self.moduleContainer = self.blueprintNamespace + ':' + self.moduleNamespace + ':module_container' self.publishedNames = []
def attachGeoToBlueprint_skinning(self,blueprintJoints,geometry): blueprintModules = set([]) for joint in blueprintJoints: blueprintNamespace = utils.stripLeadingNamespace(joint)[0] blueprintModules.add(blueprintNamespace) for module in blueprintModules: cmds.lockNode(module+':module_container',lock=False, lockUnpublished=False) for geo in geometry: cmds.skinCluster(blueprintJoints, geo, tsb=True, n=geo+'_skinCluster') for module in blueprintModules: cmds.lockNode(module+':module_container',lock=True, lockUnpublished=True)
def __init__(self, moduleNamespace): self.moduleContainer = None if moduleNamespace == None: return moduleNamespaceInfo = utils.stripAllNamespaces(moduleNamespace) self.blueprintNamespace = moduleNamespaceInfo[0] self.moduleNamespace = moduleNamespaceInfo[1] self.characterNamespaceOnly = utils.stripLeadingNamespace(self.blueprintNamespace)[0] self.moduleContainer = self.blueprintNamespace + ":" + self.moduleNamespace + ":module_container" self.publisheNames = []
def lock_phase3(self,hookObject): moduleContainer = (self.moduleNamespace + ':module_container') if hookObject != None: hookObjectModuleNode = utils.stripLeadingNamespace(hookObject) hookObjModule = hookObjectModuleNode[0] hookObjJoint = hookObjectModuleNode[1].split('_translation_control')[0] hookObj = (hookObjModule + ':blueprint_' + hookObjJoint) parentConstraint = cmds.parentConstraint(hookObj, (self.moduleNamespace + ':HOOK_IN'), maintainOffset=True, n=(self.moduleNamespace + ':hook_parent_constraint'))[0] scaleConstraint = cmds.scaleConstraint(hookObj, (self.moduleNamespace + ':HOOK_IN'), maintainOffset=True, n=(self.moduleNamespace + ':hook_scale_constraint'))[0] utils.addNodeToContainer(moduleContainer, [parentConstraint,scaleConstraint]) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True)
def duplicateModule_processGroup(self, group): returnModules = [] children = cmds.listRelatives(group, children=True, type="transform") for c in children: selectionNamespaceInfo = utils.stripLeadingNamespace(c) if selectionNamespaceInfo != None: returnModules.append(selectionNamespaceInfo[0]) else: if c.find("Group__") == 0: returnModules.extend(self.duplicateModule_processGroup(c)) return returnModules
def duplicateModule(self, *args): modules = set([]) groups = set([]) selection = cmds.ls(selection=True, transforms=True) if len(selection) == 0: return for node in selection: selectionNamespaceInfo = utils.stripLeadingNamespace(node) if selectionNamespaceInfo != None: if selectionNamespaceInfo[0].find("__") != -1: modules.add(selectionNamespaceInfo[0]) else: if node.find("Group__") == 0: groups.add(node) for group in groups: moduleInfo = self.duplicateModule_processGroup(group) for module in moduleInfo: modules.add(module) if len(groups) > 0: groupSelection = list(groups) cmds.select(groupSelection, replace=True, hi=True) else: cmds.select(clear=True) for module in modules: cmds.select(module+":module_container", add=True) if len(groups) > 0: cmds.lockNode("Group_container", lock=False, lockUnpublished=False) elif len(modules) == 0: return duplicateFileName = os.environ["RIGGING_TOOL_ROOT"] + "/__duplicationCache.ma" cmds.file(duplicateFileName, exportSelected=True, type="mayaAscii", force=True) if len(groups) > 0: cmds.lockNode("Group_container", lock=True, lockUnpublished=True) self.installDuplicate(duplicateFileName, selection) cmds.setToolTo("moveSuperContext")
def duplicateModule(self, *args): modules = set([]) groups = set([]) selection = cmds.ls(selection=True, transforms=True) if len(selection) == 0: return for node in selection: selectionNamespaceInfo = utils.stripLeadingNamespace(node) if selectionNamespaceInfo != None: if selectionNamespaceInfo[0].find('__') != -1: modules.add(selectionNamespaceInfo[0]) else: if node.find('Group__') == 0: groups.add(node) for group in groups: moduleInfo = self.duplicateModule_processGroup(group) for module in moduleInfo: modules.add(module) if len(groups) > 0: groupSelection = list(groups) cmds.select(groupSelection, replace=True, hi=True) else: cmds.select(clear=True) for module in modules: cmds.select(module+':module_container',add=True) if len(groups) > 0: cmds.lockNode('Group_container', lock=False, lockUnpublished=False) elif len(modules) == 0: return duplicateFileName = os.environ['RIGGING_TOOL_ROOT']+'/__duplicationCache.ma' cmds.file(duplicateFileName, exportSelected=True, type='mayaAscii', force=True) if len(groups) > 0: cmds.lockNode('Group_container', lock=True, lockUnpublished=True) self.installDuplicate(duplicateFileName, selection) cmds.setToolTo('moveSuperContext')
def initialiseBlueprintModuleList(self): cmds.namespace(setNamespace=self.selectedCharacter) blueprintNamespaces = cmds.namespaceInfo(listOnlyNamespaces=True) cmds.namespace(setNamespace=":") # Dictionary containing full names of blueprint modules self.blueprintModules = {} if len(blueprintNamespaces) > 0: for namespace in blueprintNamespaces: blueprintModule = utils.stripLeadingNamespace(namespace)[1] userSpecifiedName = blueprintModule.partition("__")[2] cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], edit=True, append=userSpecifiedName) self.blueprintModules[userSpecifiedName] = namespace cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], edit=True, selectIndexedItem=1) selectedBlprnModule = cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], q=True, selectItem=True) self.selectedBlueprintModule = self.blueprintModules[selectedBlprnModule[0]]
def createGroup(self, groupName): fullGroupName = ('Group__' + groupName) if cmds.objExists(fullGroupName): cmds.confirmDialog(title='Name Conflic', message=('Group \'' + groupName + '\'already exists'), button='Accept', defaultButton='Accept') return None groupTransform = cmds.rename(self.tempGroupTransform, fullGroupName) groupContainer = 'Group_container' if not cmds.objExists(groupContainer): cmds.container(name=groupContainer) containers = [groupContainer] for obj in self.objectsToGroup: if obj.find('Group__') == 0: continue objNamespace = utils.stripLeadingNamespace(obj)[0] containers.append(objNamespace + ':module_container') for c in containers: cmds.lockNode(c,lock=False, lockUnpublished=False) if len(self.objectsToGroup) != 0: tempGroup = cmds.group(self.objectsToGroup, absolute=True) groupParent = cmds.listRelatives(tempGroup, parent=True) if groupParent != None: cmds.parent(groupTransform, groupParent[0], absolute=True) cmds.parent(self.objectsToGroup, groupTransform, absolute=True) cmds.delete(tempGroup) self.addGroupToContainer(groupTransform) for c in containers: cmds.lockNode(c,lock=True, lockUnpublished=True) cmds.setToolTo('moveSuperContext') cmds.select(groupTransform, replace=True) return groupTransform
def createGroup(self, groupName): fullGroupName = "Group__" + groupName if cmds.objExists(fullGroupName): cmds.confirmDialog(title="Name Conflict", message="Group \"" + groupName + "\" already exists",button="Accept", defaultButton = "Accept") return None groupTransform = cmds.rename(self.tempGroupTransform, fullGroupName) groupContainer = "Group_container" if not cmds.objExists(groupContainer): cmds.container(name=groupContainer) containers = [groupContainer] for obj in self.objectsToGroup: if obj.find("Group__") == 0: continue objNamespace = utils.stripLeadingNamespace(obj)[0] containers.append(objNamespace+":module_container") for c in containers: cmds.lockNode(c, lock=False, lockUnpublished=False) if len(self.objectsToGroup) != 0: tempGroup = cmds.group(self.objectsToGroup, absolute=True) groupParent = cmds.listRelatives( tempGroup, parent=True) if groupParent != None: cmds.parent( groupTransform, groupParent[0], absolute=True) cmds.parent(self.objectsToGroup, groupTransform, absolute=True) cmds.delete(tempGroup) self.addGroupToContainer(groupTransform) for c in containers: cmds.lockNode(c, lock=True, lockUnpublished=True) cmds.setToolTo("moveSuperContext") cmds.select(groupTransform, replace=True) return groupTransform
def findChildModules(self,group): modules = [] children = cmds.listRelatives(group, children=True) if children != None: for child in children: moduleNamespaceInfo = utils.stripLeadingNamespace(child) if moduleNamespaceInfo != None: modules.append(moduleNamespaceInfo[0]) elif child.find('Group__') != -1: modules.extend(self.findChildModules(child)) return modules
def initializeBlueprintModuleList(self): cmds.namespace(setNamespace=self.selectedCharacter) blueprintNamespaces = cmds.namespaceInfo(listOnlyNamespaces=True) cmds.namespace(setNamespace = ':') self.blueprintModules = {} if len(blueprintNamespaces) > 0: for namespace in blueprintNamespaces: blueprintModule = utils.stripLeadingNamespace(namespace)[1] userSpecifiedName = blueprintModule.partition('__')[2] cmds.textScrollList(self.UIElements['blueprintModule_textScroll'],edit=True,append=userSpecifiedName) self.blueprintModules[userSpecifiedName] = namespace cmds.textScrollList(self.UIElements['blueprintModule_textScroll'],edit=True, selectIndexedItem=1) selectedBlprnModule = cmds.textScrollList(self.UIElements['blueprintModule_textScroll'],q=True, selectItem=True) self.selectedBlueprintModule = self.blueprintModules[selectedBlprnModule[0]] print self.selectedBlueprintModule
def blueprintToGameName(self, capJoint, joint, capVar=True): self.capJoint = capJoint self.joint = joint self.capVar = capVar if self.capVar == True: nameVar1 = self.capJoint nameVar2 = "_cap_game_joint" if self.capVar == False: nameVar1 = self.joint nameVar2 = "_game_joint" # Create a name to use for the game joint midName = nameVar1.replace("_joint", "") tmpName = midName.split("blueprint") tmpPrefix = utils.stripLeadingNamespace(tmpName[0]) tmpName1 = (tmpPrefix[0] + tmpName[1]) tmpName2 = tmpName1.split("__") gameJointName = (tmpName2[1] + nameVar2) return gameJointName
def blueprintToGameName(self, capJoint, joint, capVar=True): self.capJoint = capJoint self.joint = joint self.capVar = capVar if self.capVar == True: nameVar1=self.capJoint nameVar2="_cap_game_joint" if self.capVar == False: nameVar1=self.joint nameVar2="_game_joint" # Create a name to use for the game joint midName = nameVar1.replace("_joint", "") tmpName = midName.split("blueprint") tmpPrefix = utils.stripLeadingNamespace(tmpName[0]) tmpName1 = (tmpPrefix[0] + tmpName[1]) tmpName2 = tmpName1.split("__") gameJointName = (tmpName2[1] + nameVar2) return gameJointName
def createUserInterface(self, blueprintModule): self.currentBlueprintModule = blueprintModule characterNamespaceInfo = utils.stripLeadingNamespace(blueprintModule) characterNamespace = characterNamespaceInfo[0] blueprintModuleNamespace = characterNamespaceInfo[1] characterName = characterNamespace.partition("__")[2] blueprintModuleInfo = blueprintModuleNamespace.partition("__") blueprintModuleName = blueprintModuleInfo[0] blueprintModuleUserSpecifiedName = blueprintModuleInfo[2] windowWidth = 600 windowHeight = 240 self.UIElements["window"] = cmds.window("modMaintain_UI_window", width=windowWidth, height=windowHeight, title="Module maintenance for "+characterName+":"+blueprintModuleUserSpecifiedName, sizeable=False) self.UIElements["topRowLayout"] = cmds.rowLayout(nc=2, columnWidth2=(296, 296), columnAttach2=("both", "both"), columnOffset2=(10, 10), rowAttach=([1, "both", 10], [2, "both", 5])) self.UIElements["controlModule_textScrollList"] = cmds.textScrollList(sc=self.UI_controlModuleSelected) for controlModule in self.controlModuleCompatibility: if blueprintModuleName in controlModule[2]: if not self.isModuleInstalled(controlModule[1]): cmds.textScrollList(self.UIElements["controlModule_textScrollList"], edit=True, append=controlModule[1]) self.UIElements["right_columnLayout"] = cmds.columnLayout(adj=True, rs=3) self.UIElements["nameText"] = cmds.text(label="No Modules To Install") self.UIElements["descriptionScrollField"] = cmds.scrollField(wordWrap=True, height=100, editable=False, text="") cmds.separator() self.UIElements["installBtn"] = cmds.button(enable=False, label="Install") if cmds.textScrollList(self.UIElements["controlModule_textScrollList"], q=True, numberOfItems=True) !=0: cmds.textScrollList(self.UIElements["controlModule_textScrollList"], edit=True, selectIndexedItem=1) self.UI_controlModuleSelected cmds.showWindow(self.UIElements["window"])
def initialiseBlueprintModuleList(self): cmds.namespace(setNamespace=self.selectedCharacter) blueprintNamespaces = cmds.namespaceInfo(listOnlyNamespaces=True) cmds.namespace(setNamespace=":") # Dictionary containing full names of blueprint modules self.blueprintModules = {} if len(blueprintNamespaces) > 0: for namespace in blueprintNamespaces: blueprintModule = utils.stripLeadingNamespace(namespace)[1] """ Add in to modify name displayed in module scroll list """ #uSpecNameA = blueprintModule.partition("__")[0] #uSpecNameB = blueprintModule.partition("__")[2] #userSpecifiedName = (uSpecNameA + "_" + uSpecNameB) userSpecifiedName = blueprintModule.partition("__")[2] cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], edit=True, append=userSpecifiedName) self.blueprintModules[userSpecifiedName] = namespace cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], edit=True, selectIndexedItem=1) selectedBlprnModule = cmds.textScrollList(self.UIElements["blueprintModule_textScroll"], q=True, selectItem=True) self.selectedBlueprintModule = self.blueprintModules[selectedBlprnModule[0]]
def createUserInterface(self,blueprintModule): self.currentBlueprintModule = blueprintModule characterNamespaceInfo = utils.stripLeadingNamespace(blueprintModule) characterNamespace = characterNamespaceInfo[0] blueprintModuleNamespace = characterNamespaceInfo[1] characterName = characterNamespace.partition('__')[2] blueprintModuleInfo = blueprintModuleNamespace.partition('__') blueprintModuleName = blueprintModuleInfo[0] blueprintModuleUserSpecifiedName = blueprintModuleInfo[2] windowWidth = 600 windowHeight = 200 self.UIElements['window'] = cmds.window('modMaintain_UI_window',width=windowWidth, height=windowHeight, title='Module maintenance for '+characterName+':'+blueprintModuleUserSpecifiedName, sizeable=False) self.UIElements['topRowLayout'] = cmds.rowLayout(nc=2, columnWidth2=(296,296), columnAttach2=('both','both'), columnOffset2=(10,10), rowAttach=([1,'both',5],[2,'both',5])) self.UIElements['controlModule_textScrolllist'] = cmds.textScrollList(sc=self.UI_controlModuleSelected) for controlModule in self.controlModuleCompatibility: if blueprintModuleName in controlModule[2]: if not self.isModuleInstalled(controlModule[1]): cmds.textScrollList(self.UIElements['controlModule_textScrolllist'],edit=True,append=controlModule[1]) self.UIElements['right_columnLayout'] = cmds.columnLayout(adj=True,rs=3) self.UIElements['nameText'] = cmds.text(label='No Animation modules to install') self.UIElements['descriptionScrollField'] = cmds.scrollField(wordWrap=True, height=110, editable=False, text='') cmds.separator() self.UIElements['installBtn'] = cmds.button(enable=False, label='Install') if cmds.textScrollList(self.UIElements['controlModule_textScrolllist'], q=True, numberOfItems=True) != 0: cmds.textScrollList(self.UIElements['controlModule_textScrolllist'], edit=True, selectIndexedItem=1) self.UI_controlModuleSelected() cmds.showWindow(self.UIElements['window'])
def attachGeoToBlueprint_skinning(self, blueprintJoints, geometry): blueprintModules = set([]) for joint in blueprintJoints: blueprintNamespace = utils.stripLeadingNamespace(joint)[0] blueprintModules.add(blueprintNamespace) for module in blueprintModules: cmds.lockNode(module + ":module_container", lock=False, lockUnpublished=False) for geo in geometry: cmds.skinCluster(blueprintJoints, geo, tsb=True, n=geo + "_skinCluster") for module in blueprintModules: cmds.lockNode(module + ":module_container", lock=True, lockUnpublished=True)
def __init__(self): selection = cmds.ls(sl=True, transforms=True) if len(selection) == 0: return firstSelected = selection[0] self.modules = [] self.group = None if firstSelected.find("Group__") == 0: self.group = firstSelected self.modules = self.findSubModules(firstSelected) else: moduleNamespaceInfo = utils.stripLeadingNamespace(firstSelected) if moduleNamespaceInfo != None: self.modules.append(moduleNamespaceInfo[0]) # 072 tempModuleList = [] for module in self.modules: if self.isModuleAMirror(module): cmds.confirmDialog( title="Mirror Module(s)", message= "Cannot mirror a previously mirrored module, aborting mirror.", button=["Accept"], defaultButton="Accept") return if not self.canModuleBeMirrored(module): print "Module \"" + module + "\" is of a module type that cannot be mirrored... skipping module." else: tempModuleList.append(module) self.modules = tempModuleList if len(self.modules) > 0: self.mirrorModule_UI()
def createTranslationControlAtJoint(self,joint): posControlFile = os.environ["RIGGING_TOOL_ROOT"] + "/ControlObjects/Blueprint/translation_control.ma" cmds.file(posControlFile, i=True) container = cmds.rename('translation_control_container', (joint + '_translation_control_container')) utils.addNodeToContainer(self.containerName, container) for node in cmds.container(container, q=True, nodeList=True): cmds.rename(node, (joint + '_' + node), ignoreShape=True) control = (joint + '_translation_control') cmds.parent(control, self.moduleTransform, absolute=True) jointPos = cmds.xform(joint, q=True, worldSpace=True, translation=True) cmds.xform(control, worldSpace=True, absolute=True, translation=jointPos) niceName = utils.stripLeadingNamespace(joint)[1] attrName = (niceName + '_T') cmds.container(container, edit=True, publishAndBind=[(control + '.translate'), attrName]) cmds.container(self.containerName, edit=True, publishAndBind=[(container + '.' + attrName), attrName]) return control
def objectSelected(self): objects = cmds.ls(selection=True) cmds.select(clear=True) if cmds.window("modMaintain_UI_window", exists=True): cmds.deleteUI("modMaintain_UI_window") characters = utils.findInstalledCharacters() for character in characters: characterContainer = character + ":character_container" cmds.lockNode(characterContainer, lock=False, lockUnpublished=False) # Find every module installed on that character. blueprintInstances = utils.findInstalledBlueprintInstances( character) for blueprintInstance in blueprintInstances: moduleContainer = character + ":" + blueprintInstance + ":module_container" cmds.lockNode(moduleContainer, lock=False, lockUnpublished=False) # Do we have modules installed? If so, set the joint color to blue. blueprintJointsGrp = character + ":" + blueprintInstance + ":blueprint_joints_grp" if cmds.getAttr(blueprintJointsGrp + ".controlModulesInstalled"): #Blue cmds.setAttr(blueprintJointsGrp + ".overrideColor", 6) else: cmds.setAttr(blueprintJointsGrp + ".overrideColor", 2) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True) cmds.lockNode(characterContainer, lock=True, lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects) - 1] lastSelected_stripNamespaces = utils.stripAllNamespaces( lastSelected) if lastSelected_stripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_stripNamespaces[ 1] if lastSelected_withoutNamespaces.find("blueprint_") == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_stripNamespaces[ 0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ":module_container" cmds.select(moduleContainer, replace=True) # set color of the joints characterNamespace = utils.stripLeadingNamespace( lastSelected)[0] characterContainer = characterNamespace + ":character_container" containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace + ":blueprint_joints_grp" # This was not in the video. I needed to add this to allow overrides. cmds.setAttr(blueprintJointsGrp + ".overrideEnabled", 1) cmds.setAttr(blueprintJointsGrp + ".overrideColor", 13) # Bring up UI self.createUserInterface( blueprintModuleNamespace_incCharNamespace) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.setupSelectionScriptJob()
def mirrorModules(self): # Make a progress bar to inform the user how long the mirror process is taking. mirrorModulesProgress_UI = cmds.progressWindow( title="Mirror Module(s)", status="This may take a few minutes...", isInterruptable=False) mirrorModulesProgress = 0 mirrorModulesProgress_stage1_proportion = 15 mirrorModulesProgress_stage2_proportion = 70 mirrorModulesProgress_stage3_proportion = 10 moduleNameInfo = utils.findAllModuleNames("/Modules/Blueprint") validModules = moduleNameInfo[0] validModuleNames = moduleNameInfo[1] for module in self.moduleInfo: moduleName = module[0].partition("__")[0] if moduleName in validModuleNames: index = validModuleNames.index(moduleName) module.append(validModules[index]) #077 mirrorModulesProgress_progressIncrement = mirrorModulesProgress_stage1_proportion / len( self.moduleInfo) for module in self.moduleInfo: userSpecifiedName = module[0].partition("__")[2] mod = __import__("Blueprint." + module[5], {}, {}, [module[5]]) reload(mod) moduleClass = getattr(mod, mod.CLASS_NAME) moduleInst = moduleClass(userSpecifiedName, None) hookObject = moduleInst.findHookObject() newHookObject = None hookModule = utils.stripLeadingNamespace(hookObject)[0] hookFound = False for m in self.moduleInfo: if hookModule == m[0]: hookFound = True if m == module: continue hookObjectName = utils.stripLeadingNamespace(hookObject)[1] newHookObject = m[1] + ":" + hookObjectName if not hookFound: newHookObject = hookObject module.append(newHookObject) hookConstrained = moduleInst.isRootConstrained() module.append(hookConstrained) mirrorModulesProgress += mirrorModulesProgress_progressIncrement cmds.progressWindow(mirrorModulesProgress_UI, edit=True, pr=mirrorModulesProgress) #078 mirrorModulesProgress_progressIncrement = mirrorModulesProgress_stage2_proportion / len( self.moduleInfo) for module in self.moduleInfo: newUserSpecifiedName = module[1].partition("__")[2] mod = __import__("Blueprint." + module[5], {}, {}, [module[5]]) reload(mod) # Create all the modules the re-hook moduleClass = getattr(mod, mod.CLASS_NAME) moduleInst = moduleClass(newUserSpecifiedName, None) moduleInst.mirror(module[0], module[2], module[3], module[4]) mirrorModulesProgress += mirrorModulesProgress_progressIncrement cmds.progressWindow(mirrorModulesProgress_UI, edit=True, pr=mirrorModulesProgress) # 083 # Mirror hooking mirrorModulesProgress_progressIncrement = mirrorModulesProgress_stage3_proportion / len( self.moduleInfo) for module in self.moduleInfo: newUserSpecifiedName = module[1].partition("__")[2] mod = __import__("Blueprint." + module[5], {}, {}, [module[5]]) reload(mod) moduleClass = getattr(mod, mod.CLASS_NAME) moduleInst = moduleClass(newUserSpecifiedName, None) moduleInst.rehook(module[6]) hookConstrained = module[7] if hookConstrained: moduleInst.constrainRootToHook() mirrorModulesProgress += mirrorModulesProgress_progressIncrement cmds.progressWindow(mirrorModulesProgress_UI, edit=True, pr=mirrorModulesProgress) #084 # Mirror Groups if self.group != None: cmds.lockNode("Group_container", lock=False, lockUnpublished=False) groupParent = cmds.listRelatives(self.group, parent=True) if groupParent != None: groupParent = groupParent[0] # Recursive method self.processGroup(self.group, groupParent) cmds.lockNode("Group_container", lock=True, lockUnpublished=True) cmds.select(clear=True) cmds.progressWindow(mirrorModulesProgress_UI, edit=True, endProgress=True) utils.forceSceneUpdate()
def modifySelected(self, *args): if cmds.checkBox(self.UIElements["symmetryMoveCheckBox"], q=True, value=True): self.deleteSymmetryMoveExpressions() self.setupSymmetryMoveExpressions() selectedNodes = cmds.ls(selection=True) if len(selectedNodes) <= 1: self.moduleInstance = None selectedModuleNamespace = None currentModuleFile = None cmds.button(self.UIElements["ungroupBtn"], edit=True, enable=False) cmds.button(self.UIElements["mirrorModuleBtn"], edit=True, enable=False) if len(selectedNodes) == 1: lastSelected = selectedNodes[0] if lastSelected.find("Group__") == 0: cmds.button(self.UIElements["ungroupBtn"], edit=True, enable=True) cmds.button(self.UIElements["mirrorModuleBtn"], edit=True, enable=True, label="Mirror Group") namespaceAndNode = utils.stripLeadingNamespace(lastSelected) if namespaceAndNode != None: namespace = namespaceAndNode[0] moduleNameInfo = utils.findAllModuleNames("/Modules/Blueprint") validModules = moduleNameInfo[0] validModuleNames = moduleNameInfo[1] index = 0 for moduleName in validModuleNames: moduleNameIncSuffix = moduleName + "__" if namespace.find(moduleNameIncSuffix) == 0: currentModuleFile = validModules[index] selectedModuleNamespace = namespace break index += 1 controlEnable = False userSpecifiedName = "" constrainCommand = self.constrainRootToHook constrainLabel = "Constrain Root > Hook" if selectedModuleNamespace != None: controlEnable = True userSpecifiedName = selectedModuleNamespace.partition("__")[2] mod = __import__("Blueprint."+currentModuleFile, {},{}, [currentModuleFile]) reload(mod) moduleClass = getattr(mod, mod.CLASS_NAME) self.moduleInstance = moduleClass(userSpecifiedName, None) cmds.button(self.UIElements["mirrorModuleBtn"], edit=True, enable=True, label="Mirror Module") if self.moduleInstance.isRootConstrained(): constrainCommand = self.unconstrainRootFromHook constrainLabel = "Unconstrain Root" #cmds.button(self.UIElements["mirrorModuleBtn"], edit=True, enable=controlEnable) cmds.button(self.UIElements["rehookBtn"], edit=True, enable=controlEnable) cmds.button(self.UIElements["snapRootBtn"], edit=True, enable=controlEnable) cmds.button(self.UIElements["constrainRootBtn"], edit=True, enable=controlEnable, label=constrainLabel, c=constrainCommand ) cmds.button(self.UIElements["deleteModuleBtn"], edit=True, enable=controlEnable, c=self.deleteModule) cmds.textField(self.UIElements["moduleName"], edit=True, enable=controlEnable, text=userSpecifiedName) self.createModuleSpecificControls() self.createScriptJob()
def setupSymmetryMoveExpressions(self, *args): cmds.namespace(setNamespace=":") selection = cmds.ls(selection=True, transforms=True) expressionContainer = cmds.container(n="symmetryMove_container") if len(selection ) == 0: return linkedObjs = [] for obj in selection: if obj in linkedObjs: continue #check if module is in a group if obj.find("Group__") == 0: if cmds.attributeQuery("mirrorLinks", n=obj, exists=True): mirrorLinks = cmds.getAttr(obj+".mirrorLinks") groupInfo = mirrorLinks.rpartition("__") mirrorObj = groupInfo[0] axis = groupInfo[2] linkedObjs.append(mirrorObj) self.setupSymmetryMoveForObject(obj, mirrorObj, axis, translation=True, orientation=True, globalScale=True) #not in a group else: #does it belong to a module objNamespaceInfo = utils.stripLeadingNamespace(obj) if objNamespaceInfo != None: #check if mirrorLinks is in module_grp if cmds.attributeQuery("mirrorLinks", n=objNamespaceInfo[0]+":module_grp", exists=True): mirrorLinks = cmds.getAttr(objNamespaceInfo[0] + ":module_grp.mirrorLinks") #split from the right base on "__" moduleInfo = mirrorLinks.rpartition("__") module = moduleInfo[0] axis = moduleInfo[2] #Searching For the control types... #The name of the node we have selected, select translation control if objNamespaceInfo[1].find("translation_control") != -1: #find out the name of the obj to drive mirrorObj = module + ":" +objNamespaceInfo[1] #put mirror object in linked obj linkedObjs.append(mirrorObj) #drive translation only self.setupSymmetryMoveForObject(obj, mirrorObj, axis, translation=True, orientation=False, globalScale=False) #select the node for module transform elif objNamespaceInfo[1].find("module_transform") == 0: mirrorObj = module + ":module_transform" #put mirror object in linked obj linkedObjs.append(mirrorObj) #drive translation and Rotate/Orientation only self.setupSymmetryMoveForObject(obj, mirrorObj, axis, translation=True, orientation=True, globalScale=False) elif objNamespaceInfo[1].find("orientation_control") != -1: mirrorObj = module + ":" + objNamespaceInfo[1] linkedObjs.append(mirrorObj) expressionString = mirrorObj + ".rotateX = "+ obj + ".rotateX; \n" expression = cmds.expression(n=mirrorObj + "_symmetryMoveExpression", string=expressionString) utils.addNodeToContainer(expressionContainer, expression) elif objNamespaceInfo[1].find("singleJointOrientation_control") != -1: mirrorObj = module + ":" + objNamespaceInfo[1] linkedObjs.append(mirrorObj) expressionString += mirrorObj + ".rotateX = " + obj + ".rotateX; \n" expressionString += mirrorObj + ".rotateY = " + obj + ".rotateY; \n" expressionString += mirrorObj + ".rotateZ = " + obj + ".rotateZ; \n" expression = cmds.expression(n=mirrorObj+"_symmetryMoveExpression", string=expressionString) utils.addNodeToContainer(expressionContainer, expression) cmds.lockNode(expressionContainer, lock=True) cmds.select(selection, replace=True)
def objectSelected(self): print "objectSelected 58" objects = cmds.ls(selection = True) cmds.select(clear=True) """ Find the installed characters """ characters = utils.findInstalledCharacters() """ Unlock the containers """ for character in characters: characterContainer = character + ":character_container" cmds.lockNode(characterContainer, lock=False, lockUnpublished=False) # Find every module installed on that character. blueprintInstances = utils.findInstalledBlueprintInstances(character) for blueprintInstance in blueprintInstances: moduleContainer = character+":"+blueprintInstance+":module_container" cmds.lockNode(moduleContainer, lock=False, lockUnpublished=False) """ Do we have modules installed? If so, set the joint color to blue. """ blueprintJointsGrp = character+":"+blueprintInstance+":blueprint_joints_grp" if cmds.getAttr(blueprintJointsGrp+".controlModulesInstalled"): #Blue cmds.setAttr(blueprintJointsGrp+".overrideColor", 6) else: cmds.setAttr(blueprintJointsGrp+".overrideColor", 2) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True) cmds.lockNode(characterContainer, lock=True, lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects)-1] lastSelected_stripNamespaces = utils.stripAllNamespaces(lastSelected) if lastSelected_stripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_stripNamespaces[1] if lastSelected_withoutNamespaces.find("blueprint_") == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_stripNamespaces[0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ":module_container" cmds.select(moduleContainer, replace=True) # set color of the joints characterNamespace = utils.stripLeadingNamespace(lastSelected)[0] characterContainer = characterNamespace + ":character_container" containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace+":blueprint_joints_grp" # This was not in the video. I needed to add this to allow overrides. cmds.setAttr(blueprintJointsGrp+".overrideEnabled", 1) cmds.setAttr(blueprintJointsGrp+".overrideColor", 13) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.currentBlueprintModule['currentMod'] = (blueprintModuleNamespace_incCharNamespace) print "ModMaintEX cureent bp mod name " print self.currentBlueprintModule['currentMod']
def objectSelected(self): objects = cmds.ls(selection = True) cmds.select(clear=True) if cmds.window("modMaintain_UI_window", exists=True): cmds.deleteUI("modMaintain_UI_window") characters = utils.findInstalledCharacters() for character in characters: characterContainer = character + ":character_container" cmds.lockNode(characterContainer, lock=False, lockUnpublished=False) # Find every module installed on that character. blueprintInstances = utils.findInstalledBlueprintInstances(character) for blueprintInstance in blueprintInstances: moduleContainer = character+":"+blueprintInstance+":module_container" cmds.lockNode(moduleContainer, lock=False, lockUnpublished=False) # Do we have modules installed? If so, set the joint color to blue. blueprintJointsGrp = character+":"+blueprintInstance+":blueprint_joints_grp" if cmds.getAttr(blueprintJointsGrp+".controlModulesInstalled"): #Blue cmds.setAttr(blueprintJointsGrp+".overrideColor", 6) else: cmds.setAttr(blueprintJointsGrp+".overrideColor", 2) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True) cmds.lockNode(characterContainer, lock=True, lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects)-1] lastSelected_stripNamespaces = utils.stripAllNamespaces(lastSelected) if lastSelected_stripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_stripNamespaces[1] if lastSelected_withoutNamespaces.find("blueprint_") == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_stripNamespaces[0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ":module_container" cmds.select(moduleContainer, replace=True) # set color of the joints characterNamespace = utils.stripLeadingNamespace(lastSelected)[0] characterContainer = characterNamespace + ":character_container" containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace+":blueprint_joints_grp" # This was not in the video. I needed to add this to allow overrides. cmds.setAttr(blueprintJointsGrp+".overrideEnabled", 1) cmds.setAttr(blueprintJointsGrp+".overrideColor", 13) # Bring up UI self.createUserInterface(blueprintModuleNamespace_incCharNamespace) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.setupSelectionScriptJob()
def objectSelected(self): objects = cmds.ls(selection=True) cmds.select(clear=True) if cmds.window("modMaintain_UI_window", exists=True): cmds.deleteUI("modMaintain_UI_window") characters = utils.findInstalledCharacters() for character in characters: characterContainer = character + ":character_container" cmds.lockNode(characterContainer, lock=False, lockUnpublished=False) blueprintInstances = utils.findInstalledBlueprintInstances( character) for blueprintInstance in blueprintInstances: moduleContainer = character + ":" + blueprintInstance + ":module_container" cmds.lockNode(moduleContainer, lock=False, lockUnpublished=False) blueprintJointsGrp = character + ":" + blueprintInstance + ":blueprint_joints_grp" if cmds.getAttr(blueprintJointsGrp + ".controlModulesInstalled"): #blue cmds.setAttr(blueprintJointsGrp + ".overrideColor", 6) else: #Grey cmds.setAttr(blueprintJointsGrp + ".overrideColor", 2) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True) cmds.lockNode(characterContainer, lock=True, lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects) - 1] lastSelected_scripNamespaces = utils.stripAllNamespaces( lastSelected) if lastSelected_scripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_scripNamespaces[ 1] if lastSelected_withoutNamespaces.find("blueprint_") == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_scripNamespaces[ 0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ":module_container" cmds.select(moduleContainer, replace=True) characterNamespace = utils.stripLeadingNamespace( lastSelected)[0] characterContainer = characterNamespace + ":character_container" containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace + ":blueprint_joints_grp" cmds.setAttr(blueprintJointsGrp + ".overrideColor", 13) self.createUserInterface( blueprintModuleNamespace_incCharNamespace) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.setupSelectionScriptJob()
def objectSelected(self): objects = cmds.ls(selection = True) cmds.select(clear=True) if cmds.window('modMaintain_UI_window',exists=True): cmds.deleteUI('modMaintain_UI_window') characters = utils.findInstalledCharacters() for character in characters: characterContainer = character + ':character_container' cmds.lockNode(characterContainer,lock=False,lockUnpublished=False) blueprintInstances = utils.findInstalledBlueprintInstances(character) for blueprintInstance in blueprintInstances: moduleContainer = character + ':' + blueprintInstance + ':module_container' cmds.lockNode(moduleContainer,lock=False,lockUnpublished=False) blueprintJointsGrp = character + ':' + blueprintInstance + ':blueprint_joints_grp' if cmds.getAttr(blueprintJointsGrp + '.controlModulesInstalled'): #blue cmds.setAttr(blueprintJointsGrp + '.overrideColor', 6) else: #Grey cmds.setAttr(blueprintJointsGrp + '.overrideColor', 2) cmds.lockNode(moduleContainer,lock=True,lockUnpublished=True) cmds.lockNode(characterContainer,lock=True,lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects)-1] lastSelected_stripNamespaces = utils.stripAllNamespaces(lastSelected) if lastSelected_stripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_stripNamespaces[1] if lastSelected_withoutNamespaces.find('blueprint_') == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_stripNamespaces[0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ':module_container' cmds.select(moduleContainer,replace=True) characterNamespace = utils.stripLeadingNamespace(lastSelected)[0] characterContainer = characterNamespace + ':character_container' containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace + ':blueprint_joints_grp' cmds.setAttr(blueprintJointsGrp + '.overrideColor', 13) self.createUserInterface(blueprintModuleNamespace_incCharNamespace) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.setupSelectionScriptJob()
def createPreferredAngleUIControl(self, preferredAngle_representation): label = utils.stripLeadingNamespace(preferredAngle_representation)[1].partition('_representation')[0] enumOptionMenu = cmds.attrEnumOptionMenu(label=label, at=preferredAngle_representation + '.axis') cmds.scriptJob(attributeChange=[preferredAngle_representation+'.axis', partial(self.attributeChange_callBackMethod,preferredAngle_representation, '.axis')],parent=enumOptionMenu)
def objectSelected(self): print "objectSelected 58" objects = cmds.ls(selection=True) cmds.select(clear=True) """ Find the installed characters """ characters = utils.findInstalledCharacters() """ Unlock the containers """ for character in characters: characterContainer = character + ":character_container" cmds.lockNode(characterContainer, lock=False, lockUnpublished=False) # Find every module installed on that character. blueprintInstances = utils.findInstalledBlueprintInstances( character) for blueprintInstance in blueprintInstances: moduleContainer = character + ":" + blueprintInstance + ":module_container" cmds.lockNode(moduleContainer, lock=False, lockUnpublished=False) """ Do we have modules installed? If so, set the joint color to blue. """ blueprintJointsGrp = character + ":" + blueprintInstance + ":blueprint_joints_grp" if cmds.getAttr(blueprintJointsGrp + ".controlModulesInstalled"): #Blue cmds.setAttr(blueprintJointsGrp + ".overrideColor", 6) else: cmds.setAttr(blueprintJointsGrp + ".overrideColor", 2) cmds.lockNode(moduleContainer, lock=True, lockUnpublished=True) cmds.lockNode(characterContainer, lock=True, lockUnpublished=True) if len(objects) > 0: lastSelected = objects[len(objects) - 1] lastSelected_stripNamespaces = utils.stripAllNamespaces( lastSelected) if lastSelected_stripNamespaces != None: lastSelected_withoutNamespaces = lastSelected_stripNamespaces[ 1] if lastSelected_withoutNamespaces.find("blueprint_") == 0: blueprintModuleNamespace_incCharNamespace = lastSelected_stripNamespaces[ 0] moduleContainer = blueprintModuleNamespace_incCharNamespace + ":module_container" cmds.select(moduleContainer, replace=True) # set color of the joints characterNamespace = utils.stripLeadingNamespace( lastSelected)[0] characterContainer = characterNamespace + ":character_container" containers = [characterContainer, moduleContainer] for container in containers: cmds.lockNode(container, lock=False, lockUnpublished=False) blueprintJointsGrp = blueprintModuleNamespace_incCharNamespace + ":blueprint_joints_grp" # This was not in the video. I needed to add this to allow overrides. cmds.setAttr(blueprintJointsGrp + ".overrideEnabled", 1) cmds.setAttr(blueprintJointsGrp + ".overrideColor", 13) for container in containers: cmds.lockNode(container, lock=True, lockUnpublished=True) self.currentBlueprintModule['currentMod'] = ( blueprintModuleNamespace_incCharNamespace) print "ModMaintEX cureent bp mod name " print self.currentBlueprintModule['currentMod']
def delete(self): cmds.lockNode(self.containerName, lock=False, lockUnpublished=False) validModuleInfo = utils.findAllModuleNames('/Modules/Blueprint') validModules = validModuleInfo[0] validModuleNames = validModuleInfo[1] hookedModules= set() for jointInf in self.jointInfo: joint = jointInf[0] translationControl = self.getTranslationControl(self.moduleNamespace + ':' + joint) connections = cmds.listConnections(translationControl) for connection in connections: moduleInstance = utils.stripLeadingNamespace(connection) if moduleInstance != None: splitString = moduleInstance[0].partition('__') if moduleInstance[0] != self.moduleNamespace and splitString[0] in validModuleNames: index = validModuleNames.index(splitString[0]) hookedModules.add((validModules[index],splitString[2])) for module in hookedModules: mod = __import__('Blueprint.' + module[0], {},{},[module[0]]) moduleClass = getattr(mod, mod.CLASS_NAME) moduleInst = moduleClass(module[1],None) moduleInst.rehook(None) if cmds.attributeQuery('mirrorLinks', node=self.moduleNamespace + ':module_grp', exists=True): mirrorLinks = cmds.getAttr(self.moduleNamespace + ':module_grp.mirrorLinks') linkedBlueprint = mirrorLinks.rpartition('__')[0] cmds.lockNode(linkedBlueprint + ':module_container',lock=False, lockUnpublished=False) cmds.deleteAttr(linkedBlueprint + ':module_grp.mirrorLinks') cmds.lockNode(linkedBlueprint + ':module_container',lock=True, lockUnpublished=True) moduleTransform = (self.moduleNamespace + ':module_transform') moduleTransformParent = cmds.listRelatives(moduleTransform, parent=True) cmds.delete(self.containerName) cmds.namespace(setNamespace = ':') cmds.namespace(removeNamespace = self.moduleNamespace) if moduleTransformParent != None: parentGroup = moduleTransformParent[0] children = cmds.listRelatives(parentGroup, children=True) children = cmds.ls(children,transforms=True) if len(children) == 0: cmds.select(parentGroup, replace=True) import System.groupSelected as groupSelected reload(groupSelected) groupSelected.UngroupSelected()
def publish(self, *args): result = cmds.confirmDialog(messageAlign="center", title="Publish Character", message="The action of publishing cannot be undone.\nAre you sure you wish to continue?",button=["Accept","Cancel"], defaultButton="Accept", cancelButton="Cancel", dismissString="Cancel") if result != "Accept": return result = cmds.promptDialog(title="Publish Character", message="Please specify a character name [a-z] [A-Z] and _ only: ", button=["Accept","Cancel"],defaultButton="Accept", cancelButton="Cancel", dismissString="Cancel") if result == "Accept": characterName = cmds.promptDialog(q=True, text=True) characterFileName = os.environ["RIGGING_TOOL_ROOT"]+"/Characters/"+characterName+".ma" if os.path.exists(characterFileName): cmds.confirmDialog(title="Publish Character", message="Character already exists with that name. Aborting Publish.", button=["Accept"], defaultButton="Accept") return cmds.lockNode("Scene_Locked", lock=False, lockUnpublished=False) cmds.delete("Scene_Locked") cmds.namespace(setNamespace=":") namespaces = cmds.namespaceInfo(listOnlyNamespaces=True) moduleNameInfo = utils.findAllModuleNames("/Modules/Blueprint") validModules = moduleNameInfo[0] validModuleNames = moduleNameInfo[1] foundModuleInstances = [] for n in namespaces: splitString = n.partition("__") if splitString[1] != "": module = splitString[0] if module in validModuleNames: foundModuleInstances.append(n) moduleGroups = [] moduleContainers = [] for moduleInstance in foundModuleInstances: moduleGroups.append(moduleInstance+":module_grp") moduleContainers.append(moduleInstance+":module_container") for container in moduleContainers: cmds.lockNode(container, lock=False, lockUnpublished=False) characterGroup = cmds.group(empty=True, name="character_grp") for group in moduleGroups: cmds.parent(group, characterGroup, absolute=True) cmds.select(characterGroup, replace=True) cmds.addAttr(at="bool", defaultValue=0, keyable=False, longName="moduleMaintenanceVisibility") cmds.addAttr(at="bool", defaultValue=1, keyable=True, longName="animationControlVisibility") invertModuleMaintenanceVisibility = cmds.shadingNode("reverse", n="reverse_moduleMaintenanceVisibility", asUtility=True) cmds.connectAttr(characterGroup+".moduleMaintenanceVisibility", invertModuleMaintenanceVisibility+".inputX",force=True) moduleVisibilityMultiply = cmds.shadingNode("multiplyDivide", n="moduleVisibilityMultiply", asUtility=True) cmds.connectAttr(invertModuleMaintenanceVisibility+".outputX", moduleVisibilityMultiply+".input1X") cmds.connectAttr(characterGroup+".animationControlVisibility", moduleVisibilityMultiply+".input2X") characterNodes = list(moduleContainers) characterNodes.append(characterGroup) characterNodes.append(invertModuleMaintenanceVisibility) characterNodes.append(moduleVisibilityMultiply) characterContainer = cmds.container(name="character_container") utils.addNodeToContainer(characterContainer, characterNodes) cmds.container(characterContainer, edit=True, publishAndBind=[characterGroup+".animationControlVisibility", "animControlVis"]) for container in moduleContainers: moduleNamespace = utils.stripLeadingNamespace(container)[0] blueprintJointsGrp = moduleNamespace+":blueprint_joints_grp" cmds.connectAttr(characterGroup+".moduleMaintenanceVisibility", blueprintJointsGrp+".visibility") cmds.setAttr(blueprintJointsGrp+".overrideEnabled", 1) publishedNames = cmds.container(container, q=True, publishName=True) userSpecifiedName = moduleNamespace.partition("__")[2] for name in publishedNames: cmds.container(characterContainer, edit=True, publishAndBind=[container+"."+name, userSpecifiedName+"_"+name]) characterContainers = list(moduleContainers) characterContainers.append(characterContainer) cmds.select(all=True) topLevelTransforms = cmds.ls(sl=True, transforms=True) cmds.select(clear=True) topLevelTransforms.remove(characterGroup) if len(topLevelTransforms) != 0: nonBlueprintGroup = cmds.group(topLevelTransforms, absolute=True, parent=characterGroup, name="non_blueprint_grp") cmds.setAttr(nonBlueprintGroup+".overrideEnabled", 1) cmds.setAttr(nonBlueprintGroup+".overrideDisplayType", 2) #Reference display type cmds.select(nonBlueprintGroup, replace=True) cmds.addAttr(at="bool", defaultValue=1, longName="display", k=True) visibilityMultiply = cmds.shadingNode("multiplyDivide", n="non_blueprint_visibilityMultiply", asUtility=True) cmds.connectAttr(invertModuleMaintenanceVisibility+".outputX", visibilityMultiply+".input1X", force=True) cmds.connectAttr(nonBlueprintGroup+".display", visibilityMultiply+".input2X", force=True) cmds.connectAttr(visibilityMultiply+".outputX", nonBlueprintGroup+".visibility", force=True) nonBlueprintContainer = cmds.container(addNode=nonBlueprintGroup, ihb=True, includeNetwork=True, includeShapes=True, name="non_blueprint_container") utils.addNodeToContainer(characterContainer, nonBlueprintContainer) characterContainers.append(nonBlueprintContainer) publishedName = "displayNonBlueprintNodes" cmds.container(nonBlueprintContainer, edit=True, publishAndBind=[nonBlueprintGroup+".display", publishedName]) cmds.container(characterContainer, edit=True, publishAndBind=[nonBlueprintContainer+"."+publishedName, publishedName]) for container in characterContainers: cmds.lockNode(container, lock=True, lockUnpublished=True) cmds.select(characterContainer) cmds.file(characterFileName, exportSelected=True, type="mayaAscii") scenePublished = cmds.spaceLocator(n="Scene_Published")[0] cmds.setAttr(scenePublished+".visibility", 0) cmds.lockNode(scenePublished, lock=True, lockUnpublished=True) cmds.select(clear=True) cmds.button(self.UIElements["publishBtn"], edit=True, enable=False)
def publish(self,*args): result = cmds.confirmDialog(messageAlign='center', title='Publish Character', message='The action of publishing cannot be undone. Are you sure you wish to continue?',button=['Accept','Cancel'], defaultButton='Accept',cancelButton='Cancel',dismissString='Cancel') if result != 'Accept': return result = cmds.promptDialog(title='Publish Character',message='Please specify a character name ([a-z][A-Z][0-9] and _ only):',button=['Accept','Cancel'],defaultButton='Accept',cancelButton='Cancel',dismissString='Cancel') if result == 'Accept': characterName = cmds.promptDialog(q=True, text=True) characterFileName = os.environ['RIGGING_TOOL_ROOT'] + '/Characters/' + characterName + '.ma' if os.path.exists(characterFileName): cmds.confirmDialo(title='Publish Character', message='Character already exists with that name.Aborting publish', button=['Accept'],defaultButton='Accept') return cmds.lockNode('Scene_Locked',lock=False,lockUnpublished=False) cmds.delete('Scene_Locked') cmds.namespace(setNamespace=':') namespaces = cmds.namespaceInfo(listOnlyNamespaces=True) moduleNameInfo = utils.findAllModuleNames('/Modules/Blueprint') validModules = moduleNameInfo[0] validModuleNames = moduleNameInfo[1] foundModuleInstances = [] for n in namespaces: splitString = n.partition('__') if splitString[1] != '': module = splitString[0] if module in validModuleNames: foundModuleInstances.append(n) moduleGroups = [] moduleContainers = [] for moduleInstance in foundModuleInstances: moduleGroups.append(moduleInstance + ':module_grp') moduleContainers.append(moduleInstance + ':module_container') for container in moduleContainers: cmds.lockNode(container,lock=False,lockUnpublished=False) characterGroup = cmds.group(empty=True, name='character_grp') for group in moduleGroups: cmds.parent(group,characterGroup, absolute=True) cmds.select(characterGroup, replace=True) cmds.addAttr(at='bool', defaultValue=0,keyable=False,longName='moduleMaintenanceVisibility') cmds.addAttr(at='bool', defaultValue=1,keyable=True,longName='animationControlVisibility') invertModuleMaintenanceVisibility = cmds.shadingNode('reverse',n='reverse_moduleMaintenanceVisibility',asUtility=True) cmds.connectAttr(characterGroup+'.moduleMaintenanceVisibility',invertModuleMaintenanceVisibility+'.inputX',force=True) moduleVisibilityMultiply = cmds.shadingNode('multiplyDivide',n='moduleVisibilityMultiply',asUtility=True) cmds.connectAttr(invertModuleMaintenanceVisibility+'.outputX',moduleVisibilityMultiply+'.input1X') cmds.connectAttr(characterGroup+'.animationControlVisibility',moduleVisibilityMultiply+'.input2X') characterNodes = list(moduleContainers) characterNodes.append(characterGroup) characterNodes.append(invertModuleMaintenanceVisibility) characterNodes.append(moduleVisibilityMultiply) characterContainer = cmds.container(name='character_container') utils.addNodeToContainer(characterContainer, characterNodes) cmds.container(characterContainer,edit=True,publishAndBind=[characterGroup+'.animationControlVisibility','animControlVis']) for container in moduleContainers: moduleNamespace = utils.stripLeadingNamespace(container)[0] blueprintJointsGrp = moduleNamespace+':blueprint_joints_grp' cmds.connectAttr(characterGroup+'.moduleMaintenanceVisibility', blueprintJointsGrp+'.visibility') cmds.setAttr(blueprintJointsGrp+'.overrideEnabled',1) publishedNames = cmds.container(container,q=True, publishName=True) userSpecifiedName = moduleNamespace.partition('__')[2] for name in publishedNames: cmds.container(characterContainer,edit=True,publishAndBind=[container+'.'+name, userSpecifiedName+'_'+name]) characterContainers = list(moduleContainers) characterContainers.append(characterContainer) cmds.select(all=True) topLevelTransforms = cmds.ls(sl=True, transforms=True) cmds.select(clear=True) topLevelTransforms.remove(characterGroup) if len(topLevelTransforms) != 0: nonBlueprintGroup = cmds.group(topLevelTransforms, absolute=True, parent=characterGroup,name='non_blueprint_grp') cmds.setAttr(nonBlueprintGroup+'.overrideEnabled',1) cmds.setAttr(nonBlueprintGroup+'.overrideDisplayType',2)#Reference display type cmds.select(nonBlueprintGroup,replace=True) cmds.addAttr(at='bool',defaultValue=1, longName='display',k=True) visibilityMultiply = cmds.shadingNode('multiplyDivide', n='non_blueprint_visibilityMultiply',asUtility=True) cmds.connectAttr(invertModuleMaintenanceVisibility+'.outputX',visibilityMultiply+'.input1X',force=True) cmds.connectAttr(nonBlueprintGroup+'.display',visibilityMultiply+'.input2X',force=True) cmds.connectAttr(visibilityMultiply+'.outputX',nonBlueprintGroup+'.visibility',force=True) nonBlueprintContainer = cmds.container(addNode=nonBlueprintGroup, ihb=True, includeNetwork=True, includeShapes=True, name='non_blueprint_container') utils.addNodeToContainer(characterContainer,nonBlueprintContainer) characterContainers.append(nonBlueprintContainer) publishedName = 'displayNonBlueprintNodes' cmds.container(nonBlueprintContainer, edit=True, publishAndBind=[nonBlueprintGroup+'.display',publishedName]) cmds.container(characterContainer, edit=True, publishAndBind=[nonBlueprintContainer+'.'+publishedName,publishedName]) for container in characterContainers: cmds.lockNode(container, lock=True,lockUnpublished=True) cmds.select(characterContainer) cmds.file(characterFileName,exportSelected=True, type='mayaAscii') scenePublished = cmds.spaceLocator(n='Scene_Published')[0] cmds.setAttr(scenePublished+'.visibility',0) cmds.lockNode(scenePublished,lock=True,lockUnpublished=True) cmds.select(clear=True) cmds.button(self.UIElements['publishBtn'],edit=True,enable=False)
def modifySelected(self,*args): if cmds.checkBox(self.UIElements['symmetryMoveCheckBox'],q=True,value=True): self.deleteSymmetryMoveExpressions() self.setupSymmetryMoveExpressions() #video 45 selectedNodes = cmds.ls(selection=True) if len(selectedNodes) <= 1: self.moduleInstance = None selectedModuleNamespace = None currentModuleFile = None cmds.button(self.UIElements['ungroupBtn'], edit=True, enable=False) cmds.button(self.UIElements['mirrorModuleBtn'], edit=True, enable=False) if len(selectedNodes) == 1: lastSelected = selectedNodes[0] if lastSelected.find('Group__') == 0: cmds.button(self.UIElements['ungroupBtn'], edit=True, enable=True) cmds.button(self.UIElements['mirrorModuleBtn'], edit=True, enable=True, label='Mirror Group') namespaceAndNode = utils.stripLeadingNamespace(lastSelected) if namespaceAndNode != None: namespace = namespaceAndNode[0] moduleNameInfo = utils.findAllModuleNames('/Modules/Blueprint') validModules = moduleNameInfo[0] validModuleNames = moduleNameInfo[1] index = 0 for moduleName in validModuleNames: moduleNameIncSuffix = moduleName + '__' if namespace.find(moduleNameIncSuffix) == 0: currentModuleFile = validModules[index] selectedModuleNamespace = namespace break index += 1 controlEnable = False userSpecifiedName = '' constrainCommand = self.constrainRootToHook constrainLabel = 'Constrain Root> Hook' if selectedModuleNamespace != None: controlEnable = True userSpecifiedName = selectedModuleNamespace.partition('__')[2] mod = __import__('Blueprint.' + currentModuleFile, {},{},[currentModuleFile]) reload(mod) moduleClass = getattr(mod,mod.CLASS_NAME) self.moduleInstance = moduleClass(userSpecifiedName, None) cmds.button(self.UIElements['mirrorModuleBtn'], edit=True, enable=True, label='Mirror Module') if self.moduleInstance.isRootConstrained(): constrainCommand = self.unconstrainRootFromHook constrainLabel = 'Unconstrain Root' cmds.button(self.UIElements['rehookBtn'],edit=True, enable=controlEnable) cmds.button(self.UIElements['snapRootBtn'],edit=True, enable=controlEnable) cmds.button(self.UIElements['constrainRootBtn'],edit=True, enable=controlEnable, label=constrainLabel, c=constrainCommand) cmds.button(self.UIElements['deleteModuleBtn'],edit=True, enable=controlEnable, c=self.deleteModule) cmds.textField(self.UIElements['moduleName'],edit=True, enable=controlEnable, text=userSpecifiedName) self.createModuleSpecificControls() self.createScriptJob()
def setupSymmetryMoveExpressions(self, *args): cmds.namespace(setNamespace = ':') selection=cmds.ls(selection=True, transforms=True) expressionContainer = cmds.container(n='symmetryMove_container') if len(selection) == 0: return linkedObjs = [] for obj in selection: if obj in linkedObjs: continue if obj.find('Group__') == 0: if cmds.attributeQuery('mirrorLinks', n=obj, exists=True): mirrorLinks = cmds.getAttr(obj + '.mirrorLinks') groupInfo = mirrorLinks.rpartition('__') mirrorObj = groupInfo[0] axis = groupInfo[2] linkedObjs.append(mirrorObj) self.setupSymmetryMoveForObject(obj,mirrorObj,axis,translation=True,orientation=True, globalScale=True) else: objNamespaceInfo = utils.stripLeadingNamespace(obj) if objNamespaceInfo != None: if cmds.attributeQuery('mirrorLinks', n=objNamespaceInfo[0] + ':module_grp', exists=True): mirrorLinks = cmds.getAttr(objNamespaceInfo[0] + ':module_grp.mirrorLinks') moduleInfo = mirrorLinks.rpartition('__') module = moduleInfo[0] axis = moduleInfo[2] if objNamespaceInfo[1].find('translation_control') != -1: mirrorObj = module + ':' + objNamespaceInfo[1] linkedObjs.append(mirrorObj) self.setupSymmetryMoveForObject(obj, mirrorObj, axis, translation=True, orientation=False, globalScale=False) elif objNamespaceInfo[1].find('module_transform') == 0: mirrorObj = module + ':module_transform' linkedObjs.append(mirrorObj) self.setupSymmetryMoveForObject(obj, mirrorObj, axis, translation=True, orientation=True, globalScale=True) elif objNamespaceInfo[1].find('orientation_control') != -1: mirrorObj = module + ':' + objNamespaceInfo[1] linkedObjs.append(mirrorObj) expressionString = mirrorObj + '.rotateX = ' + obj + '.rotateX;\n' expression = cmds.expression(n=mirrorObj + '_symmetryMoveExpression', string=expressionString) utils.addNodeToContainer(expressionContainer, expression) elif objNamespaceInfo[1].find('singleJointOrientation_control') != -1: mirrorObj = module + ':' + objNamespaceInfo[1] linkedObjs.append(mirrorObj) expressionString = mirrorObj + '.rotateX = ' + obj + '.rotateX;\n' expressionString += mirrorObj + '.rotateY = ' + obj + '.rotateY;\n' expressionString += mirrorObj + '.rotateZ = ' + obj + '.rotateZ;\n' expression = cmds.expression(n=mirrorObj + '_symmetryMoveExpression', string=expressionString) utils.addNodeToContainer(expressionContainer, expression) cmds.lockNode(expressionContainer, lock=True) cmds.select(selection,replace=True)