Python maya.cmds.select() Examples

The following are 30 code examples for showing how to use maya.cmds.select(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .

Example 1
Project: dpAutoRigSystem   Author: nilouco   File: dpSelectAllControls.py    License: GNU General Public License v2.0 8 votes vote down vote up
def dpSelectAllCtrls(self, allGrpNode, *args):
        """ Select all controls using All_Grp.
        """
        ctrlsToSelectList = []
        if cmds.objExists(allGrpNode+"."+self.ctrlsAttr):
            ctrlsAttr = cmds.getAttr(allGrpNode+"."+self.ctrlsAttr)
            if ctrlsAttr:
                currentNamespace = ""
                if ":" in allGrpNode:
                    currentNamespace = allGrpNode[:allGrpNode.find(":")]
                ctrlsList = ctrlsAttr.split(";")
                if ctrlsList:
                    for ctrlName in ctrlsList:
                        if ctrlName:
                            if currentNamespace:
                                ctrlsToSelectList.append(currentNamespace+":"+ctrlName)
                            else:
                                ctrlsToSelectList.append(ctrlName)
                    cmds.select(ctrlsToSelectList)
                    print self.langDic[self.langName]["m169_selectedCtrls"]+str(ctrlsToSelectList)
            else:
                mel.eval("warning \""+self.langDic[self.langName]["e019_notFoundAllGrp"]+"\";") 
Example 2
Project: dpAutoRigSystem   Author: nilouco   File: dpIsolate.py    License: GNU General Public License v2.0 7 votes vote down vote up
def dpIsolate(self, attrName, nodeList, *args):
        """ Function to run isolate setup.
        """
        # get father zero out transform node
        zeroGrp = cmds.listRelatives(nodeList[2], allParents=True, type="transform")[0]
        # create parent constraint
        pConst = cmds.parentConstraint(nodeList[0], nodeList[1], zeroGrp, maintainOffset=True, skipTranslate=["x", "y", "z"])[0]
        # add isolate attribute to selected control
        cmds.addAttr(nodeList[2], longName=attrName, defaultValue=1.0, minValue=0, maxValue=1, keyable=True) 
        # create reverse node
        reverseNode = cmds.createNode('reverse', name=nodeList[2]+"_"+attrName.capitalize()+"_Rev")
        # do isolate connections
        cmds.connectAttr(nodeList[2]+"."+attrName, pConst+"."+nodeList[0]+"W0", force=True)
        cmds.connectAttr(nodeList[2]+"."+attrName, reverseNode+".inputX", force=True)
        cmds.connectAttr(reverseNode+".outputX", pConst+"."+nodeList[1]+"W1", force=True)
        cmds.select(nodeList[2]) 
Example 3
Project: core   Author: getavalon   File: lib.py    License: MIT License 6 votes vote down vote up
def maintained_selection():
    """Maintain selection during context

    Example:
        >>> scene = cmds.file(new=True, force=True)
        >>> node = cmds.createNode("transform", name="Test")
        >>> cmds.select("persp")
        >>> with maintained_selection():
        ...     cmds.select("Test", replace=True)
        >>> "Test" in cmds.ls(selection=True)
        False

    """

    previous_selection = cmds.ls(selection=True)
    try:
        yield
    finally:
        if previous_selection:
            cmds.select(previous_selection,
                        replace=True,
                        noExpand=True)
        else:
            cmds.select(clear=True) 
Example 4
Project: dpAutoRigSystem   Author: nilouco   File: dpBaseControlClass.py    License: GNU General Public License v2.0 6 votes vote down vote up
def getControlUIValues(self, cvName='', *args):
        """ Check and get all UI values to define variables.
            Return them in a list:
            [cvName, cvSize, cvDegree, cvDirection, cvAction]
        """
        # here we will use all info from UI elements in order to call the correct action to do:
        customName = cmds.textFieldGrp(self.dpUIinst.allUIs["controlNameTFG"], query=True, text=True)
        self.cvName = cvName
        if customName:
            self.cvName = customName
        # action
        self.cvAction = cmds.radioButtonGrp(self.dpUIinst.allUIs["controlActionRBG"], query=True, select=True)
        # degree
        degreeRBGValue = cmds.radioButtonGrp(self.dpUIinst.allUIs["degreeRBG"], query=True, select=True)
        self.cvDegree = 1 #linear
        if degreeRBGValue == 2:
            self.cvDegree = 3 #cubic
        # size
        self.cvSize = cmds.floatSliderGrp(self.dpUIinst.allUIs["controlSizeFSG"], query=True, value=True)
        # direction
        self.cvDirection = cmds.optionMenuGrp(self.dpUIinst.allUIs["directionOMG"], query=True, value=True)
        return [self.cvName, self.cvSize, self.cvDegree, self.cvDirection, self.cvAction] 
Example 5
Project: dpAutoRigSystem   Author: nilouco   File: dpCopySkin.py    License: GNU General Public License v2.0 6 votes vote down vote up
def dpCopySkin(self, sourceItem, destinationList, skinInfList, *args):
        """ Do the copy skin from sourceItem to destinationList using the skinInfList.
        """
        for item in destinationList:
            # get correct naming
            skinClusterName = utils.extractSuffix(item)
            if "|" in skinClusterName:
                skinClusterName = skinClusterName[skinClusterName.rfind("|")+1:]
            # create skinCluster node
            cmds.skinCluster(skinInfList, item, name=skinClusterName+"_SC", toSelectedBones=True, maximumInfluences=3, skinMethod=0)
            cmds.select(sourceItem)
            cmds.select(item, toggle=True)
            # copy skin weights from sourceItem to item node
            cmds.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["label", "oneToOne", "closestJoint"])
            # log result
            print self.langDic[self.langName]['i083_copiedSkin'], sourceItem, item 
Example 6
Project: dpAutoRigSystem   Author: nilouco   File: dpControls.py    License: GNU General Public License v2.0 6 votes vote down vote up
def renameShape(self, transformList, *args):
        """Find shapes, rename them to Shapes and return the results.
        """
        resultList = []
        for transform in transformList:
            # list all children shapes:
            childShapeList = cmds.listRelatives(transform, shapes=True, children=True, fullPath=True)
            if childShapeList:
                # verify if there is only one shape and return it renamed:
                if len(childShapeList) == 1:
                    shape = cmds.rename(childShapeList[0], transform+"Shape")
                    cmds.select(clear=True)
                    resultList.append(shape)
                # else rename and return one list of renamed shapes:
                elif len(childShapeList) > 1:
                    for i, child in enumerate(childShapeList):
                        shape = cmds.rename(child, transform+str(i)+"Shape")
                        resultList.append(shape)
                    cmds.select(clear=True)
            else:
                print "There are not children shape to rename inside of:", transform
        return resultList 
Example 7
Project: maya-spline-ik   Author: robertjoosten   File: curve.py    License: GNU General Public License v3.0 6 votes vote down vote up
def convertToBezierCurve(curve):
    """
    Check if the parsed curve is a bezier curve, if this is not the case
    convert the curve to a bezier curve.
    
    :param str curve: Name of curve
    """
    # get shape
    curveShape = cmds.listRelatives(curve, s=True)[0]

    # convert to bezier curve
    if cmds.nodeType(curveShape) == "bezierCurve":
        return
        
    cmds.select(curve)
    cmds.nurbsCurveToBezier()


# ---------------------------------------------------------------------------- 
Example 8
Project: spore   Author: wiremas   File: test_instance_data.py    License: MIT License 6 votes vote down vote up
def setUp(self):

        # create new scene & load plugin
        cmds.file(new=True, f=True)
        plugin = 'spore'
        self.load_plugin('spore')

        # setup a simple scene
        plane = cmds.polyPlane()
        cone = cmds.polyCone()
        cmds.select(plane[0], cone[0])
        spore = cmds.spore()

        # get new instance data object and connect it to the current node
        self.node = node_utils.get_mobject_from_name(spore[0])
        self.instance_data = instance_data.InstanceData(self.node)
        self.instance_data.initialize_data() 
Example 9
Project: spore   Author: wiremas   File: test_geo_cache.py    License: MIT License 6 votes vote down vote up
def setUp(self):

        # create new scene & load plugin
        cmds.file(new=True, f=True)
        plugin = 'spore'
        self.load_plugin('spore')

        # setup a simple scene
        plane = cmds.polyPlane(sx=10, sy=10, w=10, h=10)
        #  cone = cmds.polyCone()
        #  cmds.select(plane[0], cone[0])
        #  spore = cmds.spore()

        # get new instance data object and connect it to the current node
        #  self.node = node_utils.get_mobject_from_name(spore[0])
        self.plane = node_utils.get_dagpath_from_name(plane[0])
        self.geo_cache = geo_cache.GeoCache() 
Example 10
Project: spore   Author: wiremas   File: manager.py    License: MIT License 6 votes vote down vote up
def item_clicked(self, widget, event):

        item_name = widget.long_name
        item_state = widget.is_selected
        if cmds.objExists(item_name):

            is_modified = event.modifiers() == Qt.ControlModifier
            if not is_modified:
                cmds.select(clear=True)

            for geo_item, spore_items in self.wdg_tree.iteritems():
                for spore_item in spore_items:
                    if is_modified \
                    and spore_item.is_selected:
                        cmds.select(spore_item.long_name, add=True)
                    else:
                        spore_item.deselect()
                        cmds.select(spore_item.long_name, deselect=True)

            widget.set_select(item_state)
            if not is_modified:
                cmds.select(item_name)

        else:
            self.refresh_spore() 
Example 11
Project: spore   Author: wiremas   File: manager.py    License: MIT License 6 votes vote down vote up
def context_request(self, widget, action):

        if action.text() == 'Delete':
            selection = cmds.ls(sl=1, typ='sporeNode')
            for geo_wdg, spore_wdgs in self.wdg_tree.iteritems():
                for spore_wdg in spore_wdgs:

                    spore_node = spore_wdg.name
                    print spore_node
                    if spore_wdg.is_selected and cmds.objExists(spore_node):
                        instancer = node_utils.get_instancer(spore_node)
                        transform = cmds.listRelatives(spore_node, p=True, f=True)

                        if len(cmds.listRelatives(transform, c=1)) == 1:
                            cmds.delete((spore_node, transform[0], instancer))
                        else:
                            cmds.delete((spore_node, instancer))

                        selection.remove(spore_node)
                        cmds.select(selection)

            self.refresh_spore() 
Example 12
Project: SISideBar   Author: ShikouYamaue   File: transform.py    License: MIT License 6 votes vote down vote up
def move_center_each_object():
    object_mode = cmds.selectMode( q=True, o=True )
    cmds.selectMode(o=True)
    selection = cmds.ls(sl=True, l=True)
    meshes = common.search_polygon_mesh(selection, fullPath=True, nurbs=True)
    if not meshes:
        return
    dummy = common.TemporaryReparent().main(mode='create')
    for m in meshes:
        cmds.selectMode(o=True)
        common.TemporaryReparent().main(m, dummyParent=dummy, mode='cut')
        cmds.select(m, r=True)
        if not object_mode:
            cmds.selectMode(co=True)
        move_center2selection()
        common.TemporaryReparent().main(m, dummyParent=dummy, mode='parent')
    common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
    freeze.main(mesh=selection)
    cmds.select(selection, r=True) 
Example 13
Project: SISideBar   Author: ShikouYamaue   File: normal.py    License: MIT License 6 votes vote down vote up
def convert_edge_lock():
    sel = cmds.ls(sl=True, l=True)
    meshes = common.search_polygon_mesh(sel, serchChildeNode=False)
    if not meshes:
        return
    for mesh in meshes:
        d_mesh = cmds.duplicate(mesh, rr=True)[0]
        modeling.setSoftEdge(mesh, angle=120)
        cmds.transferAttributes(d_mesh, mesh,
                                flipUVs=0, 
                                transferPositions=0, 
                                transferUVs=0, 
                                sourceUvSpace="map1", 
                                searchMethod=3, 
                                transferNormals=1, 
                                transferColors=0, 
                                targetUvSpace="map1", 
                                colorBorders=1, 
                                sampleSpace=5)
        freeze.main(mesh)
        cmds.polyNormalPerVertex(mesh, ufn=True)
        cmds.delete(d_mesh)
    cmds.select(meshes) 
Example 14
Project: DeformationLearningSolver   Author: WebberHuang   File: miscFunc.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def applyDeltaMush(smooth=1.0, iterations=20, useBuildIn=False):
    """
    Args:
      smooth (float)
      iterations (int)
    """
    sel = cmds.ls(sl=1, ap=1)

    if not sel:
        om.MGlobal.displayError("Please select a few meshes.")
        return

    if useBuildIn:
        cmds.deltaMush(sel, si=iterations, ss=smooth, pbv=0)
    else:
        cmds.wbDeltaMush(sel, si=iterations, ss=smooth, pbv=0)

#---------------------------------------------------------------------- 
Example 15
Project: DeformationLearningSolver   Author: WebberHuang   File: utils.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def getDagPathComponents(compList):
    """
    Args:
      compList (list)

    Returns:
      MObject
    """

    currSel = cmds.ls(sl=1, l=1)
    cmds.select(compList, r=1)
    selList = om.MSelectionList()
    om.MGlobal.getActiveSelectionList(selList)
    dagPath = om.MDagPath()
    components = om.MObject()
    selList.getDagPath(0, dagPath, components)
    cmds.select(cl=1)
    try:
        cmds.select(currSel, r=1)
    except:
        pass
    return dagPath, components

#---------------------------------------------------------------------- 
Example 16
Project: maya-skinning-tools   Author: robertjoosten   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def contextMenuEvent(self, event):    
        menu = Qt.QMenu(self)
        influence = menu.addAction(
            "Select: Influence", 
            partial(
                cmds.select, 
                self.influence
            )
        )
        influence.setIcon(Qt.QIcon(SELECT_ICON))
        influence.setEnabled(True if self.influence else False)

        soft = menu.addAction(
            "Select: Soft Selection",
            self.selectSoftSelection
        )
        soft.setIcon(Qt.QIcon(SELECT_ICON))
        soft.setEnabled(True if self.ssData else False)
        
        menu.exec_(self.mapToGlobal(event.pos())) 
Example 17
Project: tutorials   Author: justinfx   File: learning.py    License: MIT License 6 votes vote down vote up
def gainLights(lightsList, gain):
	"""
	gainLights(list lightsList, float gain)
	
	Multiplies the value of gain, into the 
	intensity of every light in the scene.
	"""

	for light in lightsList:
		cmds.select(light, r=True)
		
		intens = cmds.getAttr(".intensity")
		newItensity = intens * gain
		
		cmds.setAttr(".intensity", newItensity)
		
		print "Light: %s, Old: %s, New: %s" % (light, intens, newItensity) 
Example 18
Project: dpAutoRigSystem   Author: nilouco   File: dpBaseControlClass.py    License: GNU General Public License v2.0 5 votes vote down vote up
def cvCreate(self, useUI, cvID, cvName='Control_Ctrl', cvSize=1.0, cvDegree=1, cvDirection='+Y', cvRot=(0, 0, 0), cvAction=1, dpGuide=False, combine=False, *args):
        """ Check if we need to get parameters from UI.
            Create a respective curve shape.
            Return the transform curve or a list of selected destination items.
        """
        # getting current selection:
        destinationList = cmds.ls(selection=True, type="transform")
        # check if the given name is good or add a sequencial number on it:
        self.cvName = utils.validateName(cvName, self.suffix)
        self.cvID = cvID
        self.cvSize = cvSize
        self.cvDegree = cvDegree
        self.cvDirection = cvDirection
        self.cvRot = cvRot
        self.cvAction = cvAction
        # getting UI info:
        if useUI:
            self.getControlUIValues(self.cvName)
        
        # combine or create curve using the parameters:
        if combine:
            self.cvCurve = self.generateCombineCurves(useUI, self.cvID, self.cvName, self.cvSize, self.cvDegree, self.cvDirection)
        else:
            # getting curve info to be created based on choose degree:
            if self.cvDegree == 1: #linear
                self.getLinearPoints()
            else: #cubic
                self.getCubicPoints()
            self.cvCurve = self.createCurve(self.cvName, self.cvDegree, self.cvPointList, self.cvKnotList, self.cvPeriodic, dpGuide)
        # set control direction for the control curve:
        self.setControlDirection(self.cvCurve, self.cvDirection)
        
        # working about action to do, like new control, add shape or replace shapes:
        self.doControlAction(destinationList)
        # select the result node and return it
        if self.cvAction == 1: #new control
            cmds.select(self.cvCurve)
            return self.cvCurve
        elif destinationList:
            cmds.select(destinationList)
            return destinationList 
Example 19
Project: dpAutoRigSystem   Author: nilouco   File: dpAutoRig.py    License: GNU General Public License v2.0 5 votes vote down vote up
def jobReloadUI(self, *args):
        """ This scriptJob active when we got one new scene in order to reload the UI.
        """
        import maya.cmds as cmds
        cmds.select(clear=True)
        cmds.evalDeferred("import sys; sys.modules['dpAutoRigSystem.dpAutoRig'].DP_AutoRig_UI()", lowestPriority=True) 
Example 20
Project: dpAutoRigSystem   Author: nilouco   File: dpAutoRig.py    License: GNU General Public License v2.0 5 votes vote down vote up
def populateJoints(self, *args):
        """ This function is responsable to list all joints or only dpAR joints in the interface in order to use in skinning.
        """
        # get current jointType (all or just dpAutoRig joints):
        jntSelectedRadioButton = cmds.radioCollection(self.allUIs["jntCollection"], query=True, select=True)
        chooseJnt = cmds.radioButton(jntSelectedRadioButton, query=True, annotation=True)
        
        # list joints to be populated:
        jointList, sortedJointList = [], []
        allJointList = cmds.ls(selection=False, type="joint")
        if chooseJnt == "allJoints":
            jointList = allJointList
            cmds.checkBox(self.allUIs["_JntCB"], edit=True, enable=False)
            cmds.checkBox(self.allUIs["_JisCB"], edit=True, enable=False)
        elif chooseJnt == "dpARJoints":
            cmds.checkBox(self.allUIs["_JntCB"], edit=True, enable=True)
            cmds.checkBox(self.allUIs["_JisCB"], edit=True, enable=True)
            displayJnt = cmds.checkBox(self.allUIs["_JntCB"], query=True, value=True)
            displayJis = cmds.checkBox(self.allUIs["_JisCB"], query=True, value=True)
            for jointNode in allJointList:
                if cmds.objExists(jointNode+'.'+BASE_NAME+'joint'):
                    if displayJnt:
                        if "_Jnt" in jointNode:
                            jointList.append(jointNode)
                    if displayJis:
                        if "_Jis" in jointNode:
                            jointList.append(jointNode)
        
        # sort joints by name filter:
        jointName = cmds.textField(self.allUIs["jointNameTF"], query=True, text=True)
        if jointList:
            if jointName:
                sortedJointList = utils.filterName(jointName, jointList, " ")
            else:
                sortedJointList = jointList
        
        # populate the list:
        cmds.textScrollList( self.allUIs["jntTextScrollLayout"], edit=True, removeAll=True)
        cmds.textScrollList( self.allUIs["jntTextScrollLayout"], edit=True, append=sortedJointList)
        # atualize of footerB text:
        self.atualizeSkinFooter() 
Example 21
Project: dpAutoRigSystem   Author: nilouco   File: dpFacialControl.py    License: GNU General Public License v2.0 5 votes vote down vote up
def dpChangeType(self, *args):
        """ Get and return the user selected type of controls.
            Change interface to be more clear.
        """
        typeSelectedRadioButton = cmds.radioCollection(self.typeCollection, query=True, select=True)
        self.userType = cmds.radioButton(typeSelectedRadioButton, query=True, annotation=True)
        if self.userType == TYPE_BS:
            cmds.frameLayout(self.bsLayout, edit=True, enable=True, collapse=False)
            cmds.frameLayout(self.jointsLayout, edit=True, enable=False, collapse=True)
            cmds.checkBox(self.eyelidCB, edit=True, enable=True)
        elif self.userType == TYPE_JOINTS:
            cmds.frameLayout(self.bsLayout, edit=True, enable=False, collapse=True)
            cmds.frameLayout(self.jointsLayout, edit=True, enable=True, collapse=False)
            cmds.checkBox(self.eyelidCB, edit=True, enable=False) 
Example 22
Project: dpAutoRigSystem   Author: nilouco   File: dpRivet.py    License: GNU General Public License v2.0 5 votes vote down vote up
def dpAddSelect(self, sList=None, *args):
        """ Add selected items to target textscroll list
        """
        # declare variables
        selItemList = []
        # get selection
        if sList:
            selList=sList
        else:
            selList = cmds.ls(selection=True)
        # check if there is any selected object in order to continue
        if selList:
            # find transforms
            for item in selList:
                if not item in selItemList:
                    if cmds.objectType(item) == "transform":
                        if not item == self.geoToAttach:
                            selItemList.append(item)
                    elif ".vtx" in item or ".cv" in item or ".pt" in item:
                        selItemList.append(item)
            if selItemList:
                # get current list
                currentList = cmds.textScrollList(self.itemScrollList, query=True, allItems=True)
                if currentList:
                    # clear current list
                    cmds.textScrollList(self.itemScrollList, edit=True, removeAll=True)
                    # avoid repeated items
                    for item in selItemList:
                        if not item in currentList:
                            currentList.append(item)
                    # refresh textScrollList
                    cmds.textScrollList(self.itemScrollList, edit=True, append=currentList)
                else:
                    # add selected items in the empyt target scroll list
                    cmds.textScrollList(self.itemScrollList, edit=True, append=selItemList)
            else:
                mel.eval("warning \"Please, select a tranform node, vertices or lattice points in order to add it in the item list.\";")
        else:
            mel.eval("warning \"Please, select a tranform node, vertices or lattice points in order to add it in the item list.\";") 
Example 23
Project: dpAutoRigSystem   Author: nilouco   File: sqStickyLipsSetup.py    License: GNU General Public License v2.0 5 votes vote down vote up
def sqGetPointLists(self, *args):
        cmds.select(self.baseCurve+".cv[*]")
        pointList = cmds.ls(selection=True, flatten=True)
        
        minX = 0
        maxX = 0
        sideA = 0
        sideB = 0
        for i in range(0, len(pointList)):
            pointPosX = cmds.xform(pointList[i], query=True, worldSpace=True, translation=True)[0]
            if pointPosX < minX:
                minX = pointPosX
                sideA = i
            elif pointPosX > maxX:
                maxX = pointPosX
                sideB = i
        if sideA > sideB:
            sideC = sideA
            sideA = sideB
            sideB = sideC
        
        pointListA = pointList[sideA:(sideB+1)]
        pointListB = pointList[sideB:]
        for j in range(0, (sideA+1)):
            pointListB.append(pointList[j])
        
        return pointListA, pointListB, sideA, sideB 
Example 24
Project: dpAutoRigSystem   Author: nilouco   File: sqStickyLipsSetup.py    License: GNU General Public License v2.0 5 votes vote down vote up
def sqGenerateStickyLips(self, *args):
        self.sqGetRecepts()
        if self.receptList[0] == None or self.receptList[1] == None:
            mel.eval("warning \"Please, load ReceptA and ReceptB targets to continue.\";")
        else:
            self.sqGenerateCurves()
            self.sqCreateClusters(self.baseCurveA, self.baseCurveB)
            self.sqSetClustersZeroScale()
            self.sqGenerateMuscleLocators()
            self.sqCreateStikyLipsDeformers()
            self.sqCreateStickyLipsCtrlAttr()
            cmds.select(clear=True) 
Example 25
Project: dpAutoRigSystem   Author: nilouco   File: dpSpine.py    License: GNU General Public License v2.0 5 votes vote down vote up
def reCreateEditSelectedModuleLayout(self, bSelect=False, *args):
        Layout.LayoutClass.reCreateEditSelectedModuleLayout(self, bSelect)
        # style layout:
        self.styleLayout = cmds.rowLayout(numberOfColumns=4, columnWidth4=(100, 50, 50, 70), columnAlign=[(1, 'right'), (2, 'left'), (3, 'right')], adjustableColumn=4, columnAttach=[(1, 'both', 2), (2, 'left', 2), (3, 'left', 2), (3, 'both', 10)], parent="selectedColumn")
        cmds.text(label=self.langDic[self.langName]['m041_style'], visible=True, parent=self.styleLayout)
        self.styleMenu = cmds.optionMenu("styleMenu", label='', changeCommand=self.changeStyle, parent=self.styleLayout)
        styleMenuItemList = [self.langDic[self.langName]['m042_default'], self.langDic[self.langName]['m026_biped']]
        for item in styleMenuItemList:
            cmds.menuItem(label=item, parent=self.styleMenu)
        # read from guide attribute the current value to style:
        currentStyle = cmds.getAttr(self.moduleGrp+".style")
        cmds.optionMenu(self.styleMenu, edit=True, select=int(currentStyle+1)) 
Example 26
Project: dpAutoRigSystem   Author: nilouco   File: dpControls.py    License: GNU General Public License v2.0 5 votes vote down vote up
def cvJointLoc(self, ctrlName, r=0.3, d=1, rot=(0, 0, 0), guide=True, *args):
        """Create and return a cvJointLocator curve to be usually used in the guideSystem and the clusterHandle to shapeSize.
        """
        # create locator curve:
        cvLoc = self.cvLocator(ctrlName+"_CvLoc", r, d)
        # create arrow curves:
        cvArrow1 = cmds.curve(n=ctrlName+"_CvArrow1", d=3, p=[(-0.1*r, 0.9*r, 0.2*r), (-0.1*r, 0.9*r, 0.23*r), (-0.1*r, 0.9*r, 0.27*r), (-0.1*r, 0.9*r, 0.29*r), (-0.1*r, 0.9*r, 0.3*r), (-0.372*r, 0.9*r, 0.24*r), (-0.45*r, 0.9*r, -0.13*r), (-0.18*r, 0.9*r, -0.345*r), (-0.17*r, 0.9*r, -0.31*r), (-0.26*r, 0.9*r, -0.41*r), (-0.21*r, 0.9*r, -0.41*r), (-0.05*r, 0.9*r, -0.4*r), (0, 0.9*r, -0.4*r), (-0.029*r, 0.9*r, -0.33*r), (-0.048*r, 0.9*r, -0.22*r), (-0.055*r, 0.9*r, -0.16*r), (-0.15*r, 0.9*r, -0.272*r), (-0.12*r, 0.9*r, -0.27*r), (-0.35*r, 0.9*r, -0.1*r), (-0.29*r, 0.9*r, 0.15*r), (-0.16*r, 0.9*r, 0.21*r), (-0.1*r, 0.9*r, 0.2*r)] )
        cvArrow2 = cmds.curve(n=ctrlName+"_CvArrow2", d=3, p=[(0.1*r, 0.9*r, -0.2*r), (0.1*r, 0.9*r, -0.23*r), (0.1*r, 0.9*r, -0.27*r), (0.1*r, 0.9*r, -0.29*r), (0.1*r, 0.9*r, -0.3*r), (0.372*r, 0.9*r, -0.24*r), (0.45*r, 0.9*r, 0.13*r), (0.18*r, 0.9*r, 0.345*r), (0.17*r, 0.9*r, 0.31*r), (0.26*r, 0.9*r, 0.41*r), (0.21*r, 0.9*r, 0.41*r), (0.05*r, 0.9*r, 0.4*r), (0, 0.9*r, 0.4*r), (0.029*r, 0.9*r, 0.33*r), (0.048*r, 0.9*r, 0.22*r), (0.055*r, 0.9*r, 0.16*r), (0.15*r, 0.9*r, 0.272*r), (0.12*r, 0.9*r, 0.27*r), (0.35*r, 0.9*r, 0.1*r), (0.29*r, 0.9*r, -0.15*r), (0.16*r, 0.9*r, -0.21*r), (0.1*r, 0.9*r, -0.2*r)] )
        cvArrow3 = cmds.curve(n=ctrlName+"_CvArrow3", d=3, p=[(-0.1*r, -0.9*r, 0.2*r), (-0.1*r, -0.9*r, 0.23*r), (-0.1*r, -0.9*r, 0.27*r), (-0.1*r, -0.9*r, 0.29*r), (-0.1*r, -0.9*r, 0.3*r), (-0.372*r, -0.9*r, 0.24*r), (-0.45*r, -0.9*r, -0.13*r), (-0.18*r, -0.9*r, -0.345*r), (-0.17*r, -0.9*r, -0.31*r), (-0.26*r, -0.9*r, -0.41*r), (-0.21*r, -0.9*r, -0.41*r), (-0.05*r, -0.9*r, -0.4*r), (0, -0.9*r, -0.4*r), (-0.029*r, -0.9*r, -0.33*r), (-0.048*r, -0.9*r, -0.22*r), (-0.055*r, -0.9*r, -0.16*r), (-0.15*r, -0.9*r, -0.272*r), (-0.12*r, -0.9*r, -0.27*r), (-0.35*r, -0.9*r, -0.1*r), (-0.29*r, -0.9*r, 0.15*r), (-0.16*r, -0.9*r, 0.21*r), (-0.1*r, -0.9*r, 0.2*r)] )
        cvArrow4 = cmds.curve(n=ctrlName+"_CvArrow4", d=3, p=[(0.1*r, -0.9*r, -0.2*r), (0.1*r, -0.9*r, -0.23*r), (0.1*r, -0.9*r, -0.27*r), (0.1*r, -0.9*r, -0.29*r), (0.1*r, -0.9*r, -0.3*r), (0.372*r, -0.9*r, -0.24*r), (0.45*r, -0.9*r, 0.13*r), (0.18*r, -0.9*r, 0.345*r), (0.17*r, -0.9*r, 0.31*r), (0.26*r, -0.9*r, 0.41*r), (0.21*r, -0.9*r, 0.41*r), (0.05*r, -0.9*r, 0.4*r), (0, -0.9*r, 0.4*r), (0.029*r, -0.9*r, 0.33*r), (0.048*r, -0.9*r, 0.22*r), (0.055*r, -0.9*r, 0.16*r), (0.15*r, -0.9*r, 0.272*r), (0.12*r, -0.9*r, 0.27*r), (0.35*r, -0.9*r, 0.1*r), (0.29*r, -0.9*r, -0.15*r), (0.16*r, -0.9*r, -0.21*r), (0.1*r, -0.9*r, -0.2*r)] )
        cvArrow5 = cmds.curve(n=ctrlName+"_CvArrow5", d=1, p=[(0, 0, 1.2*r), (0.09*r, 0, 1*r), (-0.09*r, 0, 1*r), (0, 0, 1.2*r)] )
        cvArrow6 = cmds.curve(n=ctrlName+"_CvArrow6", d=1, p=[(0, 0, 1.2*r), (0, 0.09*r, 1*r), (0, -0.09*r, 1*r), (0, 0, 1.2*r)] )
        # rename curveShape:
        locArrowList = [cvLoc, cvArrow1, cvArrow2, cvArrow3, cvArrow4, cvArrow5, cvArrow6]
        self.renameShape(locArrowList)
        # create ball curve:
        cvTemplateBall = self.cvControl("Ball", ctrlName+"_CvBall", r=0.7*r, d=3)
        # parent shapes to transform:
        locCtrl = cmds.group(name=ctrlName, empty=True)
        ballChildrenList = cmds.listRelatives(cvTemplateBall, shapes=True, children=True)
        for ballChildren in ballChildrenList:
            cmds.setAttr(ballChildren+".template", 1)
        self.transferShape(True, False, cvTemplateBall, [locCtrl])
        for transform in locArrowList:
            self.transferShape(True, False, transform, [locCtrl])
        # set rotation direction:
        cmds.setAttr(locCtrl+".rotateX", rot[0])
        cmds.setAttr(locCtrl+".rotateY", rot[1])
        cmds.setAttr(locCtrl+".rotateZ", rot[2])
        cmds.makeIdentity(locCtrl, rotate=True, apply=True)
        # create an attribute to be used as guide by module:
        cmds.addAttr(locCtrl, longName="nJoint", attributeType='long')
        cmds.setAttr(locCtrl+".nJoint", 1)
        # colorize curveShapes:
        self.colorShape([locCtrl], 'blue')
        # shapeSize setup:
        shapeSizeCluster = self.shapeSizeSetup(locCtrl)
        cmds.select(clear=True)
        return [locCtrl, shapeSizeCluster] 
Example 27
Project: dpAutoRigSystem   Author: nilouco   File: dpControls.py    License: GNU General Public License v2.0 5 votes vote down vote up
def cvBaseGuide(self, ctrlName, r=1, *args):
        """Create a control to be used as a Base Guide control.
            Returns the main control (circle) and the radius control in a list.
        """
        # get radius by checking linear unit
        r = self.dpCheckLinearUnit(r)
        # create a simple circle curve:
        circle = cmds.circle(n=ctrlName, ch=True, o=True, nr=(0, 0, 1), d=3, s=8, radius=r)[0]
        radiusCtrl = cmds.circle(n=ctrlName+"_RadiusCtrl", ch=True, o=True, nr=(0, 1, 0), d=3, s=8, radius=(r/4.0))[0]
        # rename curveShape:
        self.renameShape([circle, radiusCtrl])
        # configure system of limits and radius:
        cmds.setAttr(radiusCtrl+".translateX", r)
        cmds.parent(radiusCtrl, circle, relative=True)
        cmds.transformLimits(radiusCtrl, tx=(0.01, 1), etx=(True, False))
        self.setLockHide([radiusCtrl], ['ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        # find makeNurbCircle history of the circles:
        historyList = self.findHistory([circle, radiusCtrl], 'makeNurbCircle')
        circleHistory     = historyList[0]
        radiusCtrlHistory = historyList[1]
        # rename and make a connection for circle:
        circleHistory = cmds.rename(circleHistory, circle+"_makeNurbCircle")
        cmds.connectAttr(radiusCtrl+".tx", circleHistory+".radius", force=True)
        radiusCtrlHistory = cmds.rename(radiusCtrlHistory, radiusCtrl+"_makeNurbCircle")
        # create a mutiplyDivide in order to automatisation the radius of the radiusCtrl:
        radiusCtrlMD = cmds.createNode('multiplyDivide', name=radiusCtrl+'_MD')
        cmds.connectAttr(radiusCtrl+'.translateX', radiusCtrlMD+'.input1X', force=True)
        cmds.setAttr(radiusCtrlMD+'.input2X', 0.15)
        cmds.connectAttr(radiusCtrlMD+".outputX", radiusCtrlHistory+".radius", force=True)
        # colorize curveShapes:
        self.colorShape([circle], 'yellow')
        self.colorShape([radiusCtrl], 'cyan')
        if (int(cmds.about(version=True)[:4]) > 2016):
            cmds.setAttr(circle+"Shape.lineWidth", 2)
        cmds.select(clear=True)
        return [circle, radiusCtrl] 
Example 28
Project: maya-spline-ik   Author: robertjoosten   File: create.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __createJoints(self):
        # variables
        joints = []
        
        # clear selection
        cmds.select(clear=True)

        # create root joint
        root = cmds.joint(n="{0}_root_jnt".format(self.name))
        cmds.setAttr("{0}.drawStyle".format(root), 2)

        # position root joint
        pos = cmds.getAttr("{0}.result.position".format(self.pointOnCurves[0]))
        cmds.setAttr("{0}.translate".format(root), *pos[0])

        # create curve joints
        for i, _ in enumerate(self.pointOnCurves):
            cmds.select(root)

            jnt = cmds.joint(n="{0}_jnt_{1:03d}".format(self.name, i + 1))
            #cmds.setAttr("{0}.displayLocalAxis".format(jnt), 1)
            cmds.setAttr("{0}.inheritsTransform".format(jnt), 0)
            cmds.setAttr("{0}.segmentScaleCompensate".format(jnt), 0)
            cmds.setAttr("{0}.radius".format(jnt), 0.1)

            joints.append(jnt)
            
        return root, joints
        
    # ------------------------------------------------------------------------ 
Example 29
Project: spore   Author: wiremas   File: AEsporeNodeTemplate.py    License: MIT License 5 votes vote down vote up
def select_instancer(self):
        #  self._node = cmds.ls(sl=True, type='sporeNode')[-1]

        instancer = node_utils.get_instancer(self._node)
        cmds.select((instancer, self._node))

    # ------------------------------------------------------------------------ #
    # emit button
    # ------------------------------------------------------------------------ # 
Example 30
Project: spore   Author: wiremas   File: manager.py    License: MIT License 5 votes vote down vote up
def selection_changed(self, *args):
        """ link selection im maya to highligthing widgets in the manager """

        selection = cmds.ls(sl=True, typ='sporeNode', l=True)
        for geo_item, spore_items in self.wdg_tree.iteritems():
            for spore_item in spore_items:
                if spore_item.node_name in selection:
                    spore_item.select()
                else:
                    spore_item.deselect()