예제 #1
0
    def createModuleButtonCommand(self, moduleClassName, *args):

        ##  DEALING WITH NAMESPACES
        moduleName = cmds.textFieldGrp(self.UIwidgets[moduleClassName + "ModuleName"], q=True, text=True)
        if moduleName == "":
            moduleName = moduleClassName

        ##  need to check if name has "_" character in it.  If so we need to remove it.
        ##  if name does not have "_" at the end, add it
        if moduleName.partition("_")[1] == "":
            moduleName = moduleName + "_"
        ##  gather all namespaces
        allNamespaces = cmds.namespaceInfo(listNamespace=True)
        ##  gather the highest number
        index = util.findHighestTrailingNumber(allNamespaces, moduleName)
        ##  check to see if module name is in the list of namespaces.  if so, add 1.  if not leave alone
        if moduleName + str(index) in allNamespaces:
            moduleName = moduleName + str(index + 1)
        else:
            moduleName = moduleName + str(index)

        #  need to find correct module file
        modName = util.findModule(RIGGING_TOOL_ROOT, moduleClassName)
        #  import that module
        mod = __import__(environ.BlueprintModulePath + modName, {}, {}, [modName])
        reload(mod)
        # Get class reference for Blueprint module class, then create user specified instance of Blueprint module class and call it's Constructor and install method.
        #  getAttr returns import reference,
        moduleClass = getattr(mod, mod.ClassName)
        moduleInstance = moduleClass(moduleName)
        moduleInstance.install_joints()
예제 #2
0
    def moduleBuildBtn(self, *args):

        allNetworkNodes = []

        for networkNode in cmds.ls(type="network"):
            if cmds.attributeQuery("MetaNodeType", node=networkNode, exists=True):

                moduleClassName = cmds.getAttr(networkNode + ".moduleClassName")
                moduleName = cmds.getAttr(networkNode + ".moduleName")
                builtJoints = cmds.getAttr(networkNode + ".builtJoints")
                builtJoints = builtJoints.split("::")

                modName = util.findModule(RIGGING_TOOL_ROOT, moduleClassName)

                mod = __import__(environ.BlueprintModulePath + modName, {}, {}, [modName])
                reload(mod)

                moduleClass = getattr(mod, mod.ClassName)
                moduleInstance = moduleClass(moduleName)

                moduleInfo = moduleInstance.gather_jointInfo(builtJoints)

                print moduleInfo[1]
                print moduleInfo[2]

                moduleInstance.lock_joints(moduleInfo)
예제 #3
0
    def createModulesOptions(self, ClassName):

        modulesOptionsChild = cmds.frameLayout(self.UIwidgets["modulesOptionsFrameLayout"], q=True, childArray=True)
        if modulesOptionsChild != None:
            cmds.deleteUI(modulesOptionsChild)

        self.UIwidgets["modulesOptionLayout"] = cmds.formLayout(
            numberOfDivisions=100,
            w=self.moduleOptionsWidth - 5,
            height=self.moduleLayoutHeight - 5,
            parent=self.UIwidgets["modulesOptionsFrameLayout"],
        )

        self.UIwidgets[ClassName + "ModuleName"] = cmds.textFieldGrp(label="Module Name:", text=ClassName)
        cmds.textFieldGrp(
            self.UIwidgets[ClassName + "ModuleName"], edit=True, columnAttach2=["left", "left"], columnOffset2=[20, -40]
        )

        modName = util.findModule(RIGGING_TOOL_ROOT, ClassName)

        #  install custom UI
        # moduleInstance.UI_install()

        self.UIwidgets[ClassName + "CreateBtn"] = cmds.button(
            width=self.moduleOptionsWidth - 8,
            height=32,
            l="CREATE",
            bgc=[0.3, 0.64, 0.8],
            command=partial(self.createModuleButtonCommand, ClassName),
        )

        cmds.formLayout(
            self.UIwidgets["modulesOptionLayout"],
            edit=True,
            attachForm=[
                (self.UIwidgets[ClassName + "ModuleName"], "top", 10),
                (self.UIwidgets[ClassName + "ModuleName"], "left", 5),
            ],
        )
        cmds.formLayout(
            self.UIwidgets["modulesOptionLayout"],
            edit=True,
            attachForm=[
                (self.UIwidgets[ClassName + "CreateBtn"], "bottom", 5),
                (self.UIwidgets[ClassName + "CreateBtn"], "left", 0),
            ],
        )