Exemplo n.º 1
1
def mayaUIContent(parent):
    """ Contents by Maya standard UI widgets """

    layout = cmds.columnLayout(adjustableColumn=True, parent=parent)

    cmds.frameLayout("Sample Frame 1", collapsable=True)
    cmds.columnLayout(adjustableColumn=True, rowSpacing=2)
    cmds.button("maya button 1")
    cmds.button("maya button 2")
    cmds.button("maya button 3")
    cmds.setParent('..')
    cmds.setParent('..')

    cmds.frameLayout("Sample Frame 2", collapsable=True)
    cmds.gridLayout(numberOfColumns=6, cellWidthHeight=(35, 35))
    cmds.shelfButton(image1="polySphere.png", rpt=True, c=cmds.polySphere)
    cmds.shelfButton(image1="sphere.png", rpt=True, c=cmds.sphere)
    cmds.setParent('..')
    cmds.setParent('..')

    cmds.setParent('..')  # columnLayout

    ptr = OpenMayaUI.MQtUtil.findLayout(layout)
    obj = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)

    return obj
Exemplo n.º 2
0
def Create_CSGO_RIG(shelf_name=str):
    # create shelf
    mel.eval('addNewShelfTab "' + shelf_name + '" ;')
    # CREATE BUTTON
    # get csgo rig
    csgo_rig_file = open(
        PLUGINS_DIRECORY + "MP_Tools/CSGOTool_v002/csgo_tool_byMP_release.py",
        "r")
    SCRIPT_DATA = ''

    for code in csgo_rig_file:
        SCRIPT_DATA = SCRIPT_DATA + code

    image = PLUGINS_DIRECORY + "MP_Tools/CSGOTool_v002/script_ls.png"

    if SCRIPT_DATA != '':
        mc.shelfButton(
            parent=shelf_name,
            annotation="CSGO Rig Tool",
            image=image,
            command=SCRIPT_DATA,
        )
    del SCRIPT_DATA, image

    # GET DOC MAYA
    path_script = os.environ['MAYA_APP_DIR'] + '/' + mc.about(
        version=1) + '/prefs/shelves/' + shelf_name
    mc.saveShelf("CSGO", path_script)
Exemplo n.º 3
0
def add2Shelf():
    gShelfTopLevel = mel.eval('$tmpVar=$gShelfTopLevel')
    title = "ldmtButton"
    mayaScriptPath = getMayaScriptPath()
    currentShelf = cmds.tabLayout(gShelfTopLevel, h=300, q=1, st=1)
    buttonNames = cmds.shelfLayout(currentShelf, q=1, ca=1)
    for i in buttonNames:
        if i == "ldmtButton":
            return
    cmds.setParent(gShelfTopLevel + "|" + currentShelf)

    imagePath = mayaScriptPath + "/LDMT/ldmt_icon/LDMT_pro.png"
    highlightImagePath = mayaScriptPath + "/LDMT/ldmt_icon/LDMT_pro_highlight.png"
    cmds.shelfButton('ldmtButton',
                     ann="Launch LD MayaToolbox",
                     l=title,
                     image=imagePath,
                     highlightImage=highlightImagePath,
                     command='import maya.cmds as cmds\n\
import maya.mel as mel\n\
PATH_MAYA_app_dir = mel.eval("getenv MAYA_APP_DIR")\n\
sys.path.append(PATH_MAYA_app_dir+"/scripts/LDMT")\n\
sys.path.append(PATH_MAYA_app_dir+"/scripts/LDMT/ldmt_function")\n\
cmds.evalDeferred("import ldmt_ui")\n\
cmds.evalDeferred("reload(ldmt_ui)")\n\
cmds.evalDeferred("from ldmt_ui import *")\n\
cmds.evalDeferred("show()") ')
Exemplo n.º 4
0
    def addButton(self,
                  label,
                  icon="commandButton.png",
                  command=_null,
                  doubleCommand=_null,
                  noLabel=False,
                  btn_annotation=""):
        '''Adds a shelf button with the specified label, command, double click command and image.'''
        mc.setParent(self.name)
        if icon:
            icon = self.iconPath + icon

        if noLabel:
            mc.shelfButton(width=37,
                           height=37,
                           image=icon,
                           l=label,
                           command=command,
                           dcc=doubleCommand,
                           ann=btn_annotation)
        else:
            mc.shelfButton(width=37,
                           height=37,
                           image=icon,
                           l=label,
                           command=command,
                           dcc=doubleCommand,
                           imageOverlayLabel=label,
                           olb=self.labelBackground,
                           olc=self.labelColour,
                           ann=btn_annotation)
Exemplo n.º 5
0
    def manipCreator_changePivotButton(self):

        iconPivotDossier = '/autoManip/icon/pivot/'
        iconPivotPath = self.toolBoxPath + iconPivotDossier

        self.pivotButtonValue += 1

        if (self.pivotButtonValue > 6):
            self.pivotButtonValue = 0

        #_UI
        mc.shelfButton('pivotButton',
                       e=True,
                       i=(iconPivotPath + 'pivot' +
                          str(self.pivotButtonValue) + '.jpg'))

        #_SCENE

        selection = mc.ls(sl=True)

        for elem in selection:
            try:
                manip = manipsClass.manip(elem)
                manip.rBB_setPivot(self.pivotButtonValue)
            except:
                pass

        mc.select(selection)
Exemplo n.º 6
0
def create_shelf():
    """
    Create the OBB shelf

    Raises:
        None

    Returns:
        None
    """

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('OBB', exists=True)

    if shelf_exists:
        cmds.deleteUI('OBB', layout=True)

    shelf = cmds.shelfLayout('OBB', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)

    # Fix object 0 error.
    shelves = cmds.shelfTabLayout(tab_layout, query=True, tabLabelIndex=True)

    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=("shelfName%d" % (index+1), str(shelf)))
Exemplo n.º 7
0
def onMayaDroppedPythonFile(*args, **kwargs):
    """ Dragging and dropping one into the scene automatically executes it. """
    # Get icon
    icon_path = os.path.join(os.path.dirname(__file__), 'src', 'resources',
                             'icons', 'logo_jm.png')
    icon_path = os.path.normpath(icon_path)

    # Check if icon exist
    if not os.path.exists(icon_path):
        logger.error("Cannot find %s" % icon_path)
        return None

    # Check PYTHONPATH
    try:
        import jmLightToolkit
    except ImportError:
        logger.error("'jmLightToolkit' not found in PYTHON_PATH")
        return None

    # Create Shelf
    command = "import jmLightToolkit;"
    command += "jmLightToolkit.main();"
    shelf = mel.eval('$gShelfTopLevel=$gShelfTopLevel')
    parent = cmds.tabLayout(shelf, query=True, selectTab=True)

    cmds.shelfButton(command=command,
                     annotation='jmLightToolkit',
                     sourceType='Python',
                     image=icon_path,
                     image1=icon_path,
                     parent=parent)
Exemplo n.º 8
0
def InstallShelf():
    #----------------------
    # Add a shelf
    #----------------------
    shelfName = "TressFX"

    layout = mel.eval('$tmp=$gShelfTopLevel')

    if cmds.shelfLayout(
            shelfName, query=True, exists=True
    ):  # If the shelf exists, delete buttons and delete shelf
        for buttons in cmds.shelfLayout(shelfName, query=True,
                                        childArray=True) or []:
            cmds.deleteUI(buttons)

        cmds.setParent(layout + '|' + shelfName)
    else:  # If the shelf doesn't exist, create a new one
        cmds.setParent(layout)
        cmds.shelfLayout(shelfName)

    # create a button
    cmds.shelfButton(
        label='Export',
        command='import TressFX_Exporter\nTressFX_Exporter.UI()',
        #command='TressFX_Exporter.UI()',
        sourceType='python',
        annotation='Launch TressFX exporter',
        #image='', # This empty icon image will cause a warning message like 'Pixmap file  not found, using default.'.
        style='textOnly')
Exemplo n.º 9
0
def shelf():
    """
    Add a new shelf in Maya with all the tools that are provided in the
    SHELF_TOOLS variable. If the tab exists it will be deleted and re-created
    from scratch.
    """
    # get top shelf
    gShelfTopLevel = mel.eval("$tmpVar=$gShelfTopLevel")

    # get top shelf names
    shelves = cmds.tabLayout(gShelfTopLevel, query=1, ca=1)

    # delete shelf if it exists
    if SHELF_NAME in shelves:
        cmds.deleteUI(SHELF_NAME)

    # create shelf
    cmds.shelfLayout(SHELF_NAME, parent=gShelfTopLevel)

    # add modules
    for tool in SHELF_TOOLS:
        if tool.get("image1"):
            cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **tool)
        else:
            cmds.shelfButton(style="textOnly", parent=SHELF_NAME, **tool)
Exemplo n.º 10
0
def create_shelf():
    """
    Create the OBB shelf

    Raises:
        None

    Returns:
        None
    """

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('OBB', exists=True)

    if shelf_exists:
        cmds.deleteUI('OBB', layout=True)

    shelf = cmds.shelfLayout('OBB', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)

    # Fix object 0 error.
    shelves = cmds.shelfTabLayout(tab_layout, query=True, tabLabelIndex=True)

    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=("shelfName%d" % (index + 1), str(shelf)))
Exemplo n.º 11
0
    def manipCreator_changeShapeAxeButton(self):

        iconAxeDossier = '/autoManip/icon/shapeRot/'
        iconAxePath = self.toolBoxPath + iconAxeDossier

        self.shapeAxe += 1

        if (self.shapeAxe > 3):
            self.shapeAxe = 1

        #_UI
        mc.shelfButton('orientShapeButton',
                       e=True,
                       i=(iconAxePath + 'manipAxe' + str(self.shapeAxe) +
                          '.jpg'))

        #_SCENE
        manip = manipsClass.manip()

        selection = mc.ls(sl=True)

        for elem in selection:
            try:
                manip = manipsClass.manip(elem)
                manip.setShapeAxe(self.shapeAxe)
            except:
                pass

        mc.select(selection)
Exemplo n.º 12
0
def install():
    ############
    url = 'http://pepperusso.uk/scripts/notes/icon.png'  # Url of your icon
    imageName = 'notes.png'  # The icon will be saved using this name (include ext) in the icons folder of the current maya version (usually : documents/version/prefs/icons)

    name = 'Notes'  # Name to use for the shelf button
    tooltip = 'Create notes in the scene'  # Tooltip to use for the shelf button

    # Command of the shelf button.
    command = """import notes
notes.start()"""

    ############

    import maya.mel as mel
    import urllib, os

    ## Get current maya version
    version = cmds.about(version=True)

    ## Download Icon
    appPath = os.environ['MAYA_APP_DIR']
    path = os.path.join(appPath, version, "prefs/icons", imageName)
    urllib.urlretrieve(url, path)

    ## Add to current shelf
    topShelf = mel.eval('$nul = $gShelfTopLevel')
    currentShelf = cmds.tabLayout(topShelf, q=1, st=1)
    cmds.shelfButton(parent=currentShelf,
                     i=path,
                     c=command,
                     label=name,
                     annotation=tooltip)
Exemplo n.º 13
0
def install():
    """
    Add a new shelf in Maya with all the tools that are provided in the TOOLS 
    variable. If a tab already exist new buttons that weren't registered yet
    will be added to the shelf.
    """
    # get top shelf
    gShelfTopLevel = mel.eval("$tmpVar=$gShelfTopLevel")

    # get top shelf names
    shelves = cmds.tabLayout(gShelfTopLevel, query=1, ca=1)

    # create shelf if it doesn't exist yet
    if not SHELF_NAME in shelves:
        cmds.shelfLayout(SHELF_NAME, parent=gShelfTopLevel)

    # get existing members
    existing = cmds.shelfLayout(SHELF_NAME, query=True, childArray=True) or []
    existing = [cmds.shelfButton(e, query=True, label=True) for e in existing]

    # add modules
    for tool in TOOLS:
        if tool.get("label") in existing:
            continue

        if tool.get("image1"):
            cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **tool)
        else:
            cmds.shelfButton(style="textOnly", parent=SHELF_NAME, **tool)
Exemplo n.º 14
0
    def refreshShelfLayout(self, *args):
        '''Delete and the shelf buttons and remake them
        '''

        shelfButtons = mc.shelfLayout(self.shelfLayout,
                                      query=True,
                                      childArray=True)
        if shelfButtons:
            for child in shelfButtons:
                mc.deleteUI(child)

        mc.setParent(self.shelfLayout)

        for each in os.listdir(REPOSITORY_PATH):
            if each.endswith('.ctrl'):
                name = os.path.splitext(each)[0]
                icon = None
                imageFile = os.path.join(REPOSITORY_PATH, name + '.png')
                if os.path.isfile(imageFile):
                    icon = imageFile
                filename = os.path.join(REPOSITORY_PATH, each)
                button = mc.shelfButton(command=partial(importControl, name),
                                        image=icon,
                                        width=70,
                                        height=70,
                                        imageOverlayLabel=name.replace(
                                            '_', ' ').replace('  ', ' '),
                                        annotation=name)

                menus = mc.shelfButton(button, query=True, popupMenuArray=True)
                if menus:
                    for menu in menus:
                        mc.deleteUI(menu)
Exemplo n.º 15
0
 def refreshShelfLayout(self, *args):
     '''Delete and the shelf buttons and remake them
     '''
     
     shelfButtons = mc.shelfLayout(self.shelfLayout, query=True, childArray=True)
     if shelfButtons:
         for child in shelfButtons:
             mc.deleteUI(child)
     
     mc.setParent(self.shelfLayout)
     
     for each in os.listdir(REPOSITORY_PATH):
         if each.endswith('.ctrl'):
             name = os.path.splitext(each)[0]
             icon = None
             imageFile = os.path.join(REPOSITORY_PATH,name+'.png')
             if os.path.isfile(imageFile):
                 icon = imageFile
             filename = os.path.join(REPOSITORY_PATH,each)
             button = mc.shelfButton(command=partial(importControl, name),
                                     image=icon, 
                                     width=70,
                                     height=70,
                                     imageOverlayLabel=name.replace('_',' ').replace('  ',' '),
                                     annotation=name)
             
             menus = mc.shelfButton(button, query=True, popupMenuArray=True)
             if menus:
                 for menu in menus:
                     mc.deleteUI(menu)
Exemplo n.º 16
0
    def changePivotButton(self):

        iconPivotDossier = 'tools/buildManip/icon/pivot/'
        iconPivotPath = self.toolBoxPath + iconPivotDossier

        self.pivotButtonValue += 1

        if (self.pivotButtonValue > 6):
            self.pivotButtonValue = 0

        #_UI
        mc.shelfButton('pivotButton',
                       e=True,
                       i=(iconPivotPath + 'pivot' +
                          str(self.pivotButtonValue) + '.jpg'))

        #_SCENE
        print('change pivot of selected manip! --->{0}'.format(
            self.pivotButtonValue))
        selection = mc.ls(sl=True)

        for elem in selection:
            manip = buildRigClassManip.manip()
            manip.fillAttrFromRig(elem, masterRig=0)
            manip.changePivot(self.pivotButtonValue)

        mc.select(selection)
Exemplo n.º 17
0
def install_shelf():
    """
    checks if there's ngSkintTools shelf installed, and if not, creates one.

    this runs each time Maya starts (via Autoloader's ngSkinTools_load.mel) - avoid duplication, like creating things
    that already exist.
    """
    maya_shelf = mel.eval("$tempngSkinToolsVar=$gShelfTopLevel")
    existing_shelves = cmds.shelfTabLayout(maya_shelf, q=True, tabLabel=True)

    parent_shelf = 'ngSkinTools'

    if parent_shelf in existing_shelves:
        return

    mel.eval('addNewShelfTab ' + parent_shelf)
    cmds.shelfButton(
        parent=parent_shelf,
        enable=1,
        visible=1,
        preventOverride=0,
        label="ngst",
        annotation="ngSkinTools UI",
        image="ngSkinToolsShelfIcon.png",
        style="iconOnly",
        noBackground=1,
        align="center",
        marginWidth=1,
        marginHeight=1,
        command=
        "from ngSkinTools.ui.mainwindow import MainWindow\nMainWindow.open()",
        sourceType="python",
        commandRepeatable=0,
    )
Exemplo n.º 18
0
def mayaUIContent(parent):
    """ Contents by Maya standard UI widgets """

    layout = cmds.columnLayout(adjustableColumn=True, parent=parent)

    cmds.frameLayout("Sample Frame 1", collapsable=True)
    cmds.columnLayout(adjustableColumn=True, rowSpacing=2)
    cmds.button("maya button 1")
    cmds.button("maya button 2")
    cmds.button("maya button 3")
    cmds.setParent('..')
    cmds.setParent('..')

    cmds.frameLayout("Sample Frame 2", collapsable=True)
    cmds.gridLayout(numberOfColumns=6, cellWidthHeight=(35, 35))
    cmds.shelfButton(image1="polySphere.png", rpt=True, c=cmds.polySphere)
    cmds.shelfButton(image1="sphere.png", rpt=True, c=cmds.sphere)
    cmds.setParent('..')
    cmds.setParent('..')

    cmds.setParent('..')  # columnLayout

    ptr = OpenMayaUI.MQtUtil.findLayout(layout)
    obj = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)

    return obj
Exemplo n.º 19
0
    def UI_manipShape_form(self, name, parent):

        iconePivotDossier = 'buildManip/icon/shape/'

        mc.rowColumnLayout(name,
                           nc=3,
                           columnWidth=[(1, 120), (2, 10), (3, 50)],
                           p=parent)

        #---------------------------------------
        mc.rowColumnLayout(nc=1, w=120)
        mc.text(l=' ', h=15)

        mc.optionMenu('formList',
                      w=120,
                      cc=self.variableNameInGlobal + '.changeShapeFormIcon()')

        for form in self.CurveFormBank.formNames:
            mc.menuItem(l=form)

        mc.menuItem(l='>> ADD <<')

        mc.text(l=' ', h=15)
        mc.setParent(name)
        #---------------------------------------

        mc.text(l=' ')
        curentForm = mc.optionMenu('formList', q=True, v=True)
        mc.shelfButton('formPicture',
                       w=50,
                       h=50,
                       i=(self.CurveFormBank.pathPictures + curentForm +
                          '.jpg'),
                       c=self.variableNameInGlobal + '.applyShapeForm()')
Exemplo n.º 20
0
def add_shelf_button(path=None):
    """
    Setup shelf button (during installation)
    """
    
    if not path:
        path = g.plugin_path
    
    if path.endswith('/'):
        path = path[:-1]
    
    icon_path = path + '/icons/tweener-icon.png'
    
    gShelfTopLevel = mel.eval('$tmpVar=$gShelfTopLevel')
    tabs = cmds.tabLayout(gShelfTopLevel, q=True, childArray=True)
    
    for tab in tabs:
        if cmds.shelfLayout(tab, q=True, visible=True):
            cmds.shelfButton(parent=tab, ann='Open Tweener', label='Tweener',
                             image=icon_path,
                             useAlpha=True, style='iconOnly',
                             command="import maya.cmds as cmds\n"
                                     "if cmds.pluginInfo('tweener.py', q=True, r=True):\n"
                                     "\tcmds.loadPlugin('tweener.py', quiet=True)\n"
                                     "\tcmds.tweener()\n"
                                     "else:\n"
                                     "\tcmds.warning('tweener.py is not registered')")
Exemplo n.º 21
0
def anim_icon_gen(*args):
	# select -cl  ;
	# select -r lt_back_knee_PV ;
	# select -tgl lt_front_knee_PV ;
	# setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 0 {"lt_back_knee_PV", "lt_front_knee_PV"};
	# // Result: 24 //

	sel = cmds.ls(sl=1)
	anim_name = anim_field.getText()

	# mel.eval('$anim_name = circle()')
	
	if anim_radio.getSelect() == 1:
		print 'selct the given obj'

		# shelf_button = mel.eval('scriptToShelf("anim_name", $anim_name, false);')

		cmds.shelfButton(annotation='Create a cone.', image1='cone.png', command='cmds.cone()', imageOverlayLabel='4th')

		# cmds.shelfButton(i='sphere.png', c='cmds.sphere()')

		# python ("python goes here as a string");

	elif anim_radio.getSelect() == 2:
		print 'key the given attrs on the given obj'
Exemplo n.º 22
0
    def addPose(self,*args):
        cSel = cmds.ls(sl=True)
        
        if len(cSel)<1:
            cmds.warning('No objects selected..')
            sys.exit()
            
        valueDict={}
        
        sCommand = ""
        
        for i in cSel:
            attrList = cmds.listAttr(i, sa= True, k=True)
            
            for j in attrList:
                currAttr = i+'.'+j
                valueDict[currAttr] = cmds.getAttr(currAttr)
                       
        for objAttr, val in valueDict.iteritems():       
            sCommand = sCommand + "cmds.setAttr('"+objAttr+"',"+str(val)+");"
          
        
        gShelfTopLevel = mel.eval('$temp = $gShelfTopLevel')

        currentTab = cmds.tabLayout(gShelfTopLevel, query = True, st = True);
        cmds.shelfButton( annotation='User Pose', label = cSel[0], imageOverlayLabel = cSel[0], image1='commandButton.png', overlayLabelBackColor=(random.random(), random.random(), random.random(), .4), command=sCommand, parent = currentTab)
Exemplo n.º 23
0
def execute():
    """
    Add a new shelf in Maya with all the tools that are provided in the
    SHELF_TOOLS variable. If the tab exists it will be deleted and re-created
    from scratch.
    """
    shelf_main = mel.eval("$tmpVar=$gShelfTopLevel")
    shelves = cmds.tabLayout(shelf_main, query=True, childArray=True)

    if SHELF_NAME not in shelves:
        cmds.shelfLayout(SHELF_NAME, parent=shelf_main)

    names = cmds.shelfLayout(SHELF_NAME, query=True, childArray=True) or []
    labels = [cmds.shelfButton(n, query=True, label=True) for n in names]

    if SHELF_TOOL.get("label") in labels:
        index = labels.index(SHELF_TOOL.get("label"))
        cmds.deleteUI(names[index])

    if SHELF_TOOL.get("image1"):
        cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **SHELF_TOOL)
    else:
        cmds.shelfButton(style="textOnly", parent=SHELF_NAME, **SHELF_TOOL)

    log.info("transfer-blend-shape installed successfully.")
Exemplo n.º 24
0
def shelf():
    """
    Add a new shelf in Maya with the tools that is provided in the SHELF_TOOL
    variable. If the tab exists it will be checked to see if the button is
    already added. If this is the case the previous button will be deleted and
    a new one will be created in its place.
    """
    # get top shelf
    gShelfTopLevel = mel.eval("$tmpVar=$gShelfTopLevel")

    # get top shelf names
    shelves = cmds.tabLayout(gShelfTopLevel, query=1, ca=1)

    # create shelf
    if SHELF_NAME not in shelves:
        cmds.shelfLayout(SHELF_NAME, parent=gShelfTopLevel)

    # get existing members
    names = cmds.shelfLayout(SHELF_NAME, query=True, childArray=True) or []
    labels = [cmds.shelfButton(n, query=True, label=True) for n in names]

    # delete existing button
    if SHELF_TOOL.get("label") in labels:
        index = labels.index(SHELF_TOOL.get("label"))
        cmds.deleteUI(names[index])

    # add button
    cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **SHELF_TOOL)
Exemplo n.º 25
0
def hiButton(theShelf, buttonCommand, srDir):
    cmds.setParent(theShelf)
    buttonTag = True
    shelfButton = cmds.shelfLayout(theShelf, q=1, ca=1)

    if shelfButton is None:
        cmds.shelfButton(annotation=buttonAnnotation,
                         image1=srDir + theIcon,
                         command="mel.eval(\"" + buttonCommand + "\")",
                         label=buttonLabel,
                         scaleIcon=True)
        buttonTag = False
    else:
        for button in shelfButton:
            label = ""
            if cmds.objectTypeUI(button, isType="shelfButton"):
                label = str(cmds.shelfButton(button, q=1, label=1))
                if buttonLabel == label:
                    buttonTag = False
    if buttonTag:
        cmds.shelfButton(annotation=buttonAnnotation,
                         image1=srDir + theIcon,
                         command="mel.eval(\"" + buttonCommand + "\")",
                         label=buttonLabel,
                         scaleIcon=True)
Exemplo n.º 26
0
def selToShelf():
    """
	Saves all the selected textScrollList attributes to the shelf to be keyframed.
	"""
    results = cmds.promptDialog(
        title="Creating a shelf button.",
        message="Enter Shelf Button Name:",
        button=["OK", "Cancel"],
        defaultButton="OK",
        cancelButton="Cancel",
        dismissString="Cancel",
    )

    fileName = cmds.promptDialog(query=True, text=True)

    # if( results ):

    # Get the current shelf
    currentShelf = mel.eval(
        "global string $gShelfTopLevel;\rstring $shelves = `tabLayout -q -selectTab $gShelfTopLevel`;"
    )

    # Compile the info from the textScrollList
    # Get all the attrs from the textScrollList
    selectedTSL = cmds.textScrollList("sbaKeyTSL", q=True, si=True)

    # Calling my function to complies the attribute to be keyframed correctly.
    keyFrameLines = compileKeyframes(selectedTSL)

    # Create the shelfButton
    cmds.shelfButton(l=fileName, iol=fileName, c=keyFrameLines, image="setKey.xpm", parent=currentShelf)
Exemplo n.º 27
0
    def changeShapeAxeButton(self):

        iconAxeDossier = 'tools/buildManip/icon/shapeRot/'
        iconAxePath = self.toolBoxPath + iconAxeDossier

        self.shapeAxe += 1

        if (self.shapeAxe > 2):
            self.shapeAxe = 0

        #_UI
        mc.shelfButton('bmUI_manipShapeAxeButton',
                       e=True,
                       i=(iconAxePath + 'manipAxe' + str(self.shapeAxe) +
                          '.jpg'))

        print('change shape axe selection  ------> {0}'.format(self.shapeAxe))

        selection = mc.ls(sl=True)

        for elem in selection:
            manip = buildRigClassManip.manip()
            manip.fillAttrFromRig(elem, masterRig=0)
            manip.shapeForm = self.shapeForm
            manip.changeShapeAxe(self.shapeAxe)

        mc.select(selection)
Exemplo n.º 28
0
    def toggle_connect_button(self, connected):
        connect_button = self._find_button(self.connect_label)

        cmds.shelfButton(
            connect_button,
            edit=True,
            image1=self.connected_icon if connected else self.connect_icon
        )
Exemplo n.º 29
0
def updateLoadState( state ):
	existingWin = TriggeredWindow.Get()
	if existingWin:
		existingWin.updateLoadState()

	shelfButtons = getShelfButtonsWithTag( 'zooTriggered' )
	for button in shelfButtons:
		cmd.shelfButton( button, e=True, image1="zooTriggered_%d.xpm" % state )
Exemplo n.º 30
0
def add_shelf_buton(shelf_name, button_name, icon, type, command):
    cmds.shelfButton(button_name,
                     p=shelf_name,
                     i=icon,
                     c=command,
                     stp=type,
                     width=45,
                     height=44)
Exemplo n.º 31
0
def makeShelfButton(command, sourceType='python'):
    shelfLayout = mel.eval('string $temp = $gShelfTopLevel')
    shelf = cmds.tabLayout(shelfLayout, query=True, st=True)
    cmds.shelfButton(annotation='Saved selection',
                     image1='menuIconWindow.png',
                     sourceType=sourceType,
                     command=command,
                     parent=shelf)
Exemplo n.º 32
0
 def addButton(self, label, command, icon="commandButton.png", flat=0):
     mc.setParent(self.name)
     mc.shelfButton(width=50,
                    height=35,
                    image=icon,
                    l=label,
                    c=command,
                    fla=flat)
Exemplo n.º 33
0
def _load_button(button, image_dirs):

    # Defaults and basic setup.
    button.setdefault('width', 34)
    button.setdefault('height', 34)

    # Extract keys to remember buttons.
    uuids = [button.get('entrypoint'), button.pop('uuid', None)]

    # Extract other commands.
    doubleclick = button.pop('doubleclick', None)
    popup_menu = button.pop('popup_menu', None)
    context_menu = button.pop('context_menu', None)

    convert_entrypoints(button)

    # Find icons
    image_name = button.get('image')
    if image_name and not os.path.exists(image_name):
        for image_root in image_dirs:
            image_path = os.path.join(image_root, image_name)
            if os.path.exists(image_path):
                button['image'] = image_path
                break
        else:
            print 'Could not find button image:', image_name

    # Create the button!
    try:
        button['name'] = button_name = cmds.shelfButton(**button)
    except TypeError:
        print button
        raise

    # Save the button for later.
    for uuid in uuids:
        if uuid:
            _uuid_to_buttons.setdefault(uuid, []).append(button)

    # Add a doubleclick action if requested.
    if doubleclick:

        convert_entrypoints(doubleclick)

        # Only pass through the two keywords that are allowed.
        doubleclick = dict((k, v) for k, v in doubleclick.iteritems()
                           if k in ('command', 'sourceType'))

        # Adapt to a doubleclick.
        doubleclick['doubleClickCommand'] = doubleclick.pop('command')

        cmds.shelfButton(button_name, edit=True, **doubleclick)

    # Add a popup menu if requested.
    if popup_menu:
        setup_menu(shelf_button=button_name, button=1, **popup_menu)
    if context_menu:
        setup_menu(shelf_button=button_name, button=3, **context_menu)
Exemplo n.º 34
0
def handPose_fromSelect_toShelf():
    _shelfName = 'pose_Hand'
    if not cmds.shelfLayout( _shelfName, q=True, exists=True):
         mel.eval('addNewShelfTab "%s";'%_shelfName)

         _cmd  ='\n'
         _cmd +='import maya.cmds as cmds\n'
         _cmd +='import sys\n'
         _cmd +='\n'
         _cmd +=u'# 파이썬 경로 추가\n'
         _cmd +='_newPath = \'//alfredstorage/Alfred_asset/Maya_Shared_Environment/scripts_Python/Alfred_AssetTools\'\n'
         _cmd +='if not _newPath in sys.path:\n'
         _cmd +='    sys.path.append(_newPath)\n'
         _cmd +='\n'
         _cmd +=u'# UI Load\n'
         _cmd +='import Alfred_AssetTools\n'
         _cmd +='reload(Alfred_AssetTools)\n'
         _cmd +=__name__+'.handPose_fromSelect_toShelf()\n'
         
         cmds.shelfButton(
            commandRepeatable = True ,
            image1            = 'pythonFamily.png' ,
            label             = 'getHandPose',
            annotation        = 'getHandPose from Selection',
            sourceType        = 'python',
            command           = _cmd ,
            imageOverlayLabel = 'getHandPose',
            parent            = _shelfName,
            )

    _cmd = getData_from_selection()
    if not _cmd:
        return
    
    _result = cmds.promptDialog(
        title='name',
        message='pose name:',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel'
        )
    if _result != 'OK':
        print _cmd
        return

    _label = cmds.promptDialog(query=True, text=True)
    
    cmds.shelfButton(
        commandRepeatable =True ,
        image1            ='commandButton.png' ,
        label             ='handPose_'+_label ,
        annotation        ='handPose_'+_label ,
        sourceType        ='mel',
        command           = _cmd ,
        imageOverlayLabel =_label,
        parent            =_shelfName,
    )
Exemplo n.º 35
0
def _update_buttons(status):
    image = {
        None: 'publishes/check_deps_unknown.png',
        True: 'publishes/check_deps_ok.png',
        False: 'publishes/check_deps_bad.png'
    }[status]
    # print '# Setting button image to', image
    for button in mayatools.shelf.buttons_from_uuid('sgpublish.mayatools.update_references:run'):
        cmds.shelfButton(button['name'], edit=True, image=image)
Exemplo n.º 36
0
 def addButon(self, label, icon="commandButton.png", command='', doubleCommand='', docTag=None, add_doctag=None):
     cmds.setParent(self.name)
     if icon:
         icon = self.iconPath + icon
         if add_doctag: 
             cmds.shelfButton(width=37, height=37, image=icon, l=label, command=command, dcc=doubleCommand,
                              imageOverlayLabel=docTag)
         else:
             cmds.shelfButton(width=37, height=37, image=icon, l=label, command=command, dcc=doubleCommand)#,
Exemplo n.º 37
0
 def addEAtoShelf(self):
     shelf = mel.eval(
         "string $gShelfTopLevel; string $currentShelf = `tabLayout -q -st $gShelfTopLevel`;"
     )  # @UndefinedVariable
     cmds.shelfButton(rpt=True,
                      i1=self._easyAtlasIcon,
                      ann="Easy Atlas",
                      command="import easy_atlas\neasy_atlas.launch()",
                      p=shelf)  # @UndefinedVariable
Exemplo n.º 38
0
def createShelfBtn():
    currentShelf = cmds.tabLayout("ShelfLayout",selectTab=True,query=True)
    cmds.shelfButton( annotation='Delta Mush To Skin Cluster',
                      command='import dm2sc.convert as convert\nconvert.main()',
                      label='DM2SC',
                      sourceType='python',
                      image1='pythonFamily.png',
                      imageOverlayLabel='DM2SC',
                      parent=currentShelf)
Exemplo n.º 39
0
def openTool():
    window = cmds.window('Copymation Toolset', tb=False, s=False)

    #cmds.windowPref('Copymation_Toolset', ra=True)
    shelf = cmds.shelfLayout()

    button = cmds.shelfButton(annotation='Clone animation', image1='animCopymationClone.png', command='animCopymation.clone()', imageOverlayLabel='clone')

    cmds.shelfButton(annotation="Open advanced copy tool",
        image1="redo.png", command="", imageOverlayLabel="copy",
        overlayLabelColor=(1, 1, .25), overlayLabelBackColor=(.15, .9, .1, .4))

    cmds.shelfButton(annotation="Open animation cycler tool",
        image1="undo.png", command="", imageOverlayLabel="cycler",
        overlayLabelColor=(1, .25, .25))

    cmds.shelfButton(annotation="Close Copymation toolset",
        image1="close.png", command='maya.utils.executeDeferred("cmds.deleteUI(\'Copymation_Toolset\')")' , imageOverlayLabel="close",
        overlayLabelColor=(1, .25, .25))

    #resize toolset
    buttonH = cmds.shelfButton(button, q=True, h=True)
    buttonW = cmds.shelfButton(button, q=True, w=True)
    cmds.window(window, edit=True, widthHeight=(buttonW*4+10, buttonH+10))

    #show UI
    showUI()
Exemplo n.º 40
0
 def _removeFromShelf(s, name, code):
     allShelf = cmds.tabLayout(s.shelf, ca=True, q=True)
     for s in allShelf:
         buttons = cmds.shelfLayout(s, q=True, ca=True)
         if buttons:
             for b in buttons:
                 label = cmds.shelfButton(b, q=True, l=True)
                 command = cmds.shelfButton(b, q=True, c=True)
                 if label == name and command == code:
                     Say().it("Removing shelf button: %s." % b)
                     cmds.deleteUI(b, ctl=True)
Exemplo n.º 41
0
	def changeToolTip(self, toolTip, buttonText):
		###Change the tooltip from code to user friendly
		#####WARNING: Method looks at button label, not icon label, which may be different
		activeShelf = self.currentShelf()
		buttons = cmds.shelfLayout(activeShelf, query=True, childArray=True)
		# print dir(buttons[0])
		for button in buttons:
			buttonPath = activeShelf + "|" + button
			buttonLabel = cmds.shelfButton(buttonPath, query = True, label = True)
			if buttonLabel == buttonText:
				cmds.shelfButton(buttonPath, edit = True, annotation = toolTip)
Exemplo n.º 42
0
 def build(self):
     if cmds.window( 'speedWin', ex=1 ): cmds.deleteUI( 'speedWin' )
     if cmds.windowPref( 'speedWin', ex=1 ): cmds.windowPref( 'speedWin', remove=1 )
     cmds.window( 'speedWin', t='SpeedTool', wh=(350, 260))
     cmds.shelfTabLayout( 'mainShelfTab', image='smallTrash.png', imageVisible=True )
     self.shelf = cmds.shelfLayout( 'Tools', cwh=(35, 35) )
     cmds.shelfButton('save',imageOverlayLabel="save", i1='menuIconWindow.png', c=self.writeShelf)
     self.updateShelf()
     cmds.setParent( '..' )
     cmds.setParent( '..' )
     cmds.showWindow()
Exemplo n.º 43
0
 def shelfButtonHuman(self):
     children = mc.shelfLayout('Human', q=1, ca=1)
     if children == None:
         pass
     else:
         for name in children:
             oldLabel = mc.shelfButton(name, q=1, l=1)
             if oldLabel in self.flowerFacial:
                 mc.deleteUI(name, ctl=1)
     for item in self.humanFacial:
         mc.shelfButton('%s_bt'%item, l=item, w=188, h=196, image1='%s/%s.jpg'%(self.iconPath, item), annotation=item, dcc='facialPanel.update(\"' + item + '\")')
Exemplo n.º 44
0
def add_toolbox_menu():
	gridLayout= 'hj_gridLayout'
	if mc.gridLayout(gridLayout,q=1,ex=1):
		mc.deleteUI(gridLayout)

	mc.setParent('flowLayout2')
	mc.gridLayout(gridLayout,nc=1,cwh=[32,32])
	mc.setParent(gridLayout)

	global_vars = inspect.getouterframes(inspect.currentframe())[-1][0].f_globals
	# global_vars = globals()
	mc.shelfButton(i='tools.png',c=lambda *x: __import__("pyshell").main(global_vars))
Exemplo n.º 45
0
def shelfFromFile():
    """
	Creates a shelf button to keyframe the attributes straight from a previously saved file.
	"""
    # Get information from file
    # Starting at the maya folder and limiting to extension .sba
    mayaFolder = cmds.internalVar(userAppDir=True)
    # File Dialog
    # sba will be the file extension.
    filePath = cmds.fileDialog(mode=0, directoryMask=mayaFolder + "*.sba")

    print("Choosen file: " + filePath)

    # Open File
    attrFile = open(filePath, "r")  # Will overwrite the file if it allready exists!

    attrs = attrFile.readlines()

    # Close File
    attrFile.close()

    attrToShelf = []
    # loop through file content adding to the attrToShelf variable.
    for attr in attrs:
        attrToShelf.append(attr.rstrip())

    print(attrToShelf)

    results = cmds.promptDialog(
        title="Creating a shelf button.",
        message="Enter Shelf Button Name:",
        button=["OK", "Cancel"],
        defaultButton="OK",
        cancelButton="Cancel",
        dismissString="Cancel",
    )

    fileName = cmds.promptDialog(query=True, text=True)

    # if( results ):

    # Get the current shelf
    currentShelf = mel.eval(
        "global string $gShelfTopLevel;\rstring $shelves = `tabLayout -q -selectTab $gShelfTopLevel`;"
    )

    # Calling my function to complies the attribute to be keyframed correctly.
    keyFrameLines = compileKeyframes(attrToShelf)

    print(keyFrameLines)
    # Create the shelfButton
    cmds.shelfButton(l=fileName, iol=fileName, c=keyFrameLines, image="setKey.xpm", parent=currentShelf)
Exemplo n.º 46
0
def add_toolbox_menu():
    gridLayout = "hj_gridLayout"
    if mc.gridLayout(gridLayout, q=1, ex=1):
        mc.deleteUI(gridLayout)

    mc.setParent("flowLayout2")
    size = 36
    mc.gridLayout(gridLayout, nc=1, cwh=[size, size])
    mc.setParent(gridLayout)

    global_vars = inspect.getouterframes(inspect.currentframe())[-1][0].f_globals
    # global_vars = globals()
    mc.shelfButton(i="play.png", c=lambda *x: __import__("pyshell").main(global_vars), w=40)
Exemplo n.º 47
0
    def add_button(self, **kwargs):

        import sys

        # intercept/adjust some of the arguments
        for (key, val) in kwargs.iteritems():

            # get full image path
            if key.startswith("image") and IconFactory.is_icon_path(val):
                kwargs[key] = self.icon_factory.disk_path(val)

        cmds.setParent("|".join([self.layout, self.name]))
        cmds.shelfButton(**kwargs)
Exemplo n.º 48
0
def toggleIcon(off=False):
    p = Get()
    # List shelf buttons
    buttons = cmds.lsUI(type='shelfButton')
    # interate through buttons to find one using appropriate images
    for btn in buttons:
        img = cmds.shelfButton(btn, q=1, image=1)
        # toggle icon
        if img in p.iconOff or img in p.iconOn:
            if not off:
                cmds.shelfButton(btn, edit=True, image=p.iconOff)
            else:
                cmds.shelfButton(btn, edit=True, image=p.iconOn)
Exemplo n.º 49
0
def shelf() :
    
    ''' Creates a peelMocapTools shelf '''

    import maya.cmds as m
    import maya.mel as mel

    shelfTabName = "peelMocapTools"
    if not m.shelfLayout(shelfTabName, exists=True) :
       shelfTab = mel.eval("addNewShelfTab(\"%s\")" % shelfTabName)
        
    topShelf = mel.eval("global string $gShelfTopLevel; string $x = $gShelfTopLevel")
    try :
       toolShelf = m.shelfLayout("%s|%s" % (topShelf, shelfTabName), q=True, ca=True)
       if toolShelf is not None :
          if len(toolShelf) > 0 : m.deleteUI(toolShelf)
    except RuntimeError :
       x = 0

    kt = 'import mocapCleanup.keyTools as kt;kt.'
    mx = 'import mocapCleanup.mocap as mx;mx.'
    ms = 'import mocapCleanup.markerset as mz;mz.'
    la = 'import mocapCleanup.labeler as la;la.'
    ld = 'import mocapCleanup.loader as ld;ld.'
    ca = 'import mocapCleanup.camera as ca;ca.'
    
    buttons = [
      [ "Load c3d",             mx + "loadc3d()",            "mocap_loadc3d.bmp" ],
      [ "Data",                 ld + "show()",                "mocap_data.bmp"    ],
      [ "Gui",                  la + "show()",               "mocap_gui.bmp"     ],
      [ "Fill",                 kt + "fill()",               "mocap_fill.bmp"    ],
      [ "Split Parts",          kt + "splitParts()",         "mocap_splitParts.bmp" ],
      [ "Swap Selected",        kt + "swap()",               "mocap_swapSelected.bmp" ],
      [ "Swap All",             kt + "swapAll()",            "mocap_swapAll.bmp" ],
      [ "Extract Before",       kt + "extractBefore()",      "mocap_extractBefore.bmp" ],
      [ "Extract After",        kt + "extractAfter()",       "mocap_extractAfter.bmp" ],
      [ "Extract After Sel",    kt + "extractSelected()",    "mocap_extractSelected.bmp" ],
      [ "Set Current",          kt + "setCurrent('1')",      "mocap_setX.bmp" ],
      [ "Move to Current",      kt + "moveToCurrent('1')",   "mocap_moveToX.bmp" ],
      [ "Move 1 to 2",          kt + "moveFirstToSecond()",  "mocap_moveFirstToSecond.bmp" ],
      [ "Key Current to match", kt + "keyCurrentToMatch()",  "mocap_keyCurrentToMatch.bmp" ],
      [ "Go to next gap",       kt + "goToNextGap()",        "mocap_goToNextGap.bmp" ],
      [ "Toggle Active",        kt + "toggleConnectVis()",   "mocap_eye.bmp" ],
      [ "Camera On",            ca + "rigidbodyCam()",       "mocap_cam_on.bmp" ],
      [ "Camera Off",           ca + "clear()",              "mocap_cam_off.bmp" ],
    ]
    #  [ "Load web data",   "import loader\nx=loader.Loader()\nx.show()", "mocap_c3d.bmp" ],
    #  [ "Import Cameras",  "import camera\ncamera.importCameras()\n", "mocap_cam.bmp" ],
      
    for i in buttons :
      m.shelfButton(l=i[0], stp="python", c=i[1], i1=i[2], p=shelfTabName)
 def toggle_server(self, arg=None):
     if self.ServerStarted:
         self.ServerStarted = False
         self.timer.stop()
         del self.timer
         del self.receiver
         
         if cmds.window(self.winName, exists=True):
             cmds.intField(self.ui_oscport, edit=True, enable=True)
             cmds.button(self.receiveButton, edit=True, label='Start Receiving')
         
         for name in cmds.lsUI(type='shelfButton'):
             if cmds.shelfButton(name, query=True, label=True) == 'NI mate receiver':
                 cmds.setParent('MayaWindow')
                 cmds.shelfButton(name, edit=True, enableBackground=False)
     else:
         self.receiver = NImateReceiver(self.osc_port)
         self.timer = TimerObj(self.timer_exec)
         self.ServerStarted = True
         
         if cmds.window(self.winName, exists=True):
             cmds.intField(self.ui_oscport, edit=True, enable=False)
             cmds.button(self.receiveButton, edit=True, label='Stop Receiving')
         
         for name in cmds.lsUI(type='shelfButton'):
             if cmds.shelfButton(name, query=True, label=True) == 'NI mate receiver':
                 cmds.setParent('MayaWindow')
                 if self.record:
                     cmds.shelfButton(name, edit=True, enableBackground=True, backgroundColor=(1,0,0))
                 else:
                     cmds.shelfButton(name, edit=True, enableBackground=True, backgroundColor=(0,0.667,1))
Exemplo n.º 51
0
 def _addToShelf(s, name, code):
     active = cmds.tabLayout(s.shelf, st=True, q=True)  # Grab active shelf
     buttons = cmds.shelfLayout(active, q=True, ca=True)  # List all buttons in shelf
     missing = True  # Shelf button exists here?
     if buttons:
         for b in buttons:
             label = cmds.shelfButton(b, l=True, q=True)
             if label == name:
                 cmds.shelfButton(b, e=True, c=code)
                 missing = False
                 Say().it("Updated existing shelf button.")
     if missing:
         cmds.shelfButton(label=name, c=code, image="daisyLarge.png", p=active)
         Say().it("Created shelf button.")
Exemplo n.º 52
0
def Pose_obj1(Animpose_name,currentImagePath):
    frameNumber = mc.currentTime(q=1)
    frameNumber =int(frameNumber)
    iconTmp = currentImagePath + "iconTmp." + str(frameNumber)+ ".bmp" 
    print ("\niconTmp = " + iconTmp)
    Currnt_path=savepathini+'SavePose/'
    newposename=Animpose_name
    seltab1 = mc.shelfTabLayout('Poses',q=1,st=1)
    posefold=savepathini+'SavePose/Poses/'+seltab1+'/'+ newposename+'.anim'
    poseimg_path=savepathini+'SavePose/Poses/'+seltab1+'/'
    newPoseIconFile = poseimg_path + newposename +".bmp"
    if mc.file(posefold,q=1,ex=1):
        Overrite = mc.confirmDialog(
                title='Confirm Save Pose',
                message='Overwrite the existing pose: '+newposename+'?',
                button=['Yes', 'No'],
                defaultButton='Yes',
                cancelButton='No',
                dismissString='No') 
        if Overrite =='No':   
            return
    mc.sysFile(iconTmp,copy=newPoseIconFile)  

    files=open(posefold,'w')
    sel_obj  = mc.ls(sl=1)
    for each in sel_obj:
        splitter = each.split(':')
        attrs =mc.listAttr(each,k=1,u=1)
        if(len(attrs)>0):
            if len(splitter)==1:
                files.write('obj '+splitter[0]+'\n')
            else:    
                files.write('obj '+splitter[1]+'\n')    
            for eachattr in attrs:
                locked = mc.getAttr((each+'.'+eachattr),l=1)
                if not locked:
                    valStr = mc.getAttr((each+'.'+eachattr))
                    files.write(eachattr + " " +str(valStr) + '\n')   
    files.close()
    print "Pose Saved" 
                         
    mc.shelfButton(newposename,i=newPoseIconFile,w=110,h=80,l=newposename,bgc=(.6, .2, .2),st='iconAndTextVertical',p=(seltab1),c=partial(Pose_rtn,posefold))
    Refresh_UI(savepathini)
    mc.shelfTabLayout('tabs',e=1,st=Poses)   
    mc.shelfTabLayout('Poses',e=1,st=seltab1)       
    animposewinclose()
Exemplo n.º 53
0
def addButton(button):
    # create dmptools shelf button
    b = cmds.shelfButton(button['name'],
                    enableCommandRepeat=True,
                    enable=True,
                    width=34,
                    height=34,
                    manage=True,
                    visible=True,
                    image1=ICONSPATH+'/'+button['icon'],
                    label=button['name'],
                    style='iconOnly',
                    annotation=button['annotation'],
                    command=button['command'],
                    sourceType='python',
                    )
    return cmds.shelfButton(b, fpn=True, q=True)
Exemplo n.º 54
0
def setGroupState(shelf, group, state):
    shelves = getShelves()
    assert shelf in shelves, 'Cannot find shelf "' + shelf + '".'

    shelfButtons = m.shelfLayout(shelf, query=True, childArray=True, fullPathName=True)
    for btn in shelfButtons:
        btnCommandString = m.shelfButton(btn, q=True, command=True)

        match = re.search(r'.*fx_collapse_shelf_buttons\.collapse_group\s*=\s*' + re.escape(group) + r'\s+.*',
                          btnCommandString)
        if match:
            m.shelfButton(btn, e=True, visible=state)

        pattern = r"fx_collapse_shelf_buttons.toggle\(\'" + re.escape(shelf) + r"\'\,\s*\'" + re.escape(group) + r"\'\)"
        match = re.search(pattern, btnCommandString)
        if match:
            image = 'collapseBarOpened.png' if state else 'collapseBarClosed.png'
            m.shelfButton(btn, e=True, image=image, image1=image)
Exemplo n.º 55
0
def create_shelf():
    '''Create the mtoatools shelf'''

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('mtoatools', exists=True)

    if shelf_exists:
        cmds.deleteUI('mtoatools', layout=True)

    shelf = cmds.shelfLayout('mtoatools', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)
Exemplo n.º 56
0
def initializePlugin(mobject):

    ## Get the shelf configuration file
    shelfConfFile = os.path.join(prjConfFiles, "dynamicShelfConf.xml")

    ## Check if the file exist before continuing
    if os.path.exists(shelfConfFile) == True:

        ## This is a fix for the automatically saved shelf function
        ## It will delete a previously shelf created with the plugin if any exist
        mel.eval("if (`shelfLayout -exists finShelf `) deleteUI finShelf;")

        ## Declare the $gShelfTopLevel variable as a python variable
        ## The $gShelfTopLevel mel variable is the Maya default variable for the shelves bar UI
        shelfTab = mel.eval("global string $gShelfTopLevel;")
        ## Declare the $finShelf (the shelfLayout) as a global variable in order to unload it after
        mel.eval("global string $finShelf;")
        ## Create a new shelfLayout in $gShelfTopLevel
        mel.eval("$finShelf = `shelfLayout -cellWidth 33 -cellHeight 33 -p $gShelfTopLevel finShelf`;")

        ## Parse the menuConfFile
        xmlMenuDoc = minidom.parse(shelfConfFile)

        ## Loop trough each shelfItem entry in the shelfConfFile
        for eachShelfItem in xmlMenuDoc.getElementsByTagName("shelfItem"):

            ## Get the icon name
            getIcon = eachShelfItem.attributes["icon"].value
            ## Join the icon name to the icons path in order to get the full path of the icon
            shelfBtnIcon = os.path.join(iconsPath, getIcon)
            ## Get the annotation
            getAnnotation = eachShelfItem.attributes["ann"].value
            ## Get the command to launch
            getCommand = eachShelfItem.attributes["cmds"].value

            ## Create the actual shelf button with the above parameters
            cmds.shelfButton(command=getCommand, annotation=getAnnotation, image=shelfBtnIcon)

        ## Rename the shelfLayout with the prjName
        mel.eval('tabLayout -edit -tabLabel $finShelf "' + prjName + '" $gShelfTopLevel;')

        print "//-- " + prjName + " shelf successfully loaded --//"
Exemplo n.º 57
0
 def writeShelf(self, shelf):
     reload(sys)
     sys.setdefaultencoding('utf-8')
     self.allShelfButtons = []
     children = cmds.shelfLayout(shelf, q=1, ca=1)
     #children.pop(0)
     #numS = len(children)
     j = 1
     for name in children:
             oldLabel = cmds.shelfButton(name, q=1, l=1)
             oldImage = cmds.shelfButton(name, q=1, i=1)
             oldImage1 = cmds.shelfButton(name, q=1, i1=1)
             #oldCommand = cmds.shelfButton('shelfButton370', q=1, i=1)
             oldCommand = cmds.shelfButton(name, q=1, command=1)
             oldsourceType = cmds.shelfButton(name, q=1, sourceType=1)
             oldsourceOverlayLabel = cmds.shelfButton(name, q=1, imageOverlayLabel=1)
             #oldLabel.decode('gb2312')
             newCommand = self.remainCommand(oldCommand)
             newImage = self.remainImage(oldImage)
             newImage1 = self.remainImage(oldImage1)
             shelfName = "shelfButton_%s_%s"%(j, shelf)
             shelfButtonName = '%s -image "%s" -image1 "%s" -imageOverlayLabel "%s" -command "%s" -sourceType "%s" -p "%s" %s;\n'%('shelfButton', newImage, newImage1, oldsourceOverlayLabel, newCommand, oldsourceType, shelf, shelfName)
             self.allShelfButtons.append(shelfButtonName)
             j += 1
             print newCommand
     f = open('%s%s%s'%(self.tempDir, shelf, '.txt'), 'w')
     for item in self.allShelfButtons:
         f.write(item.encode('utf-8'))
     f.close
     #mm.eval('print "%s";'%tip)
     self.allShelfButtons = []
Exemplo n.º 58
0
	def createFromMaya(cls, data, control, controlType):
		btn = cls()
		if controlType == 'shelfButton':
			command = cmds.shelfButton(control, q=True, c=True)
			annotation = cmds.shelfButton(control, q=True, annotation=True)
			sType = cmds.shelfButton(control, q=True, sourceType=True)
			normal =  cmds.shelfButton(control, q=True, image=True)
			over = cmds.shelfButton(control, q=True, highlightImage=True)
			pressed = cmds.shelfButton(control, q=True, selectionImage=True)

			normal = util.resolvePath(normal)
			over = util.resolvePath(over)


			btn.setIcon(util.makeIcon(normal, over or None))
			btn.setText(command)
			btn.setToolTip(annotation or command)

		elif controlType == 'cmdScrollFieldExecuter':
			command = data.text()
			sType = cmds.cmdScrollFieldExecuter(control, q=True, sourceType=True)

			btn.setText(command)
			btn.setToolTip(command)

			if sType == 'python':
				btn.setIcon(util.makeIcon(':/pythonFamily.png'))
			else:
				btn.setIcon(util.makeIcon(':/commandButton.png'))

		else:
			log.warn('Unsuported drag and drop source: %s - %s'%(controlType, control))

		return btn
Exemplo n.º 59
0
 def writeShelf(self, *args):
     tip = u'\u606d\u559c\uff0c\u5df2\u6210\u529f\u4fdd\u5b58\uff0c\u672c\u9762\u677f\u4f1a\u7ee7\u7eed\u597d\u597d\u670d\u52a1\u7684'
     reload(sys)
     sys.setdefaultencoding('utf-8')
     allShelfButtons = []
     children = cmds.shelfLayout('Tools', q=1, ca=1)
     children.pop(0)
     numS = len(children)
     j = 1
     for name in children:
             oldLabel = cmds.shelfButton(name, q=1, l=1)
             oldImage = cmds.shelfButton(name, q=1, i=1)
             oldImage1 = cmds.shelfButton(name, q=1, i1=1)
             #oldCommand = cmds.shelfButton('shelfButton370', q=1, i=1)
             oldCommand = cmds.shelfButton(name, q=1, command=1)
             oldsourceType = cmds.shelfButton(name, q=1, sourceType=1)
             oldsourceOverlayLabel = cmds.shelfButton(name, q=1, imageOverlayLabel=1)
             #oldLabel.decode('gb2312')
             newCommand = self.remainCommand(oldCommand)
             newImage = self.remainImage(oldImage)
             newImage1 = self.remainImage(oldImage1)
             shelfName = "shelfButton_%s"%j
             shelfButtonName = '%s -image "%s" -image1 "%s" -imageOverlayLabel "%s" -command "%s" -sourceType "%s" %s;\n'%('shelfButton', newImage, newImage1, oldsourceOverlayLabel, newCommand, oldsourceType, shelfName)
             allShelfButtons.append(shelfButtonName)
             j = j + 1
             print newCommand
     f = open('%sTools.txt'%self.tempDir, 'w')
     for item in allShelfButtons:
         f.write(item.encode('utf-8'))
     f.close
     mm.eval('print "%s";'%tip)