Python maya.cmds.confirmDialog() Examples

The following are 30 code examples of maya.cmds.confirmDialog(). 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 also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def upToDateCheck(revision, prompt=True):
    '''
    This is a check that can be run by scripts that import ml_utilities to make sure they
    have the correct version.
    '''

    if not '__revision__' in locals():
        return

    if revision > __revision__:
        if prompt and mc.optionVar(query='ml_utilities_revision') < revision:
            result = mc.confirmDialog( title='Module Out of Date',
                                       message='Your version of ml_utilities may be out of date for this tool. Without the latest file you may encounter errors.',
                                       button=['Download Latest Revision','Ignore', "Don't Ask Again"],
                                       defaultButton='Download Latest Revision', cancelButton='Ignore', dismissString='Ignore' )

            if result == 'Download Latest Revision':
                mc.showHelp(GITHUB_ROOT_URL+'ml_utilities.py', absolute=True)
            elif result == "Don't Ask Again":
                mc.optionVar(intValue=('ml_utilities_revision', revision))
        return False
    return True 
Example #2
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def about(self, *args):
        '''
        This pops up a window which shows the revision number of the current script.
        '''

        text='by Morgan Loomis\n\n'
        try:
            __import__(self.module)
            module = sys.modules[self.module]
            text = text+'Revision: '+str(module.__revision__)+'\n'
        except StandardError:
            pass
        try:
            text = text+'ml_utilities Rev: '+str(__revision__)+'\n'
        except StandardError:
            pass

        mc.confirmDialog(title=self.name, message=text, button='Close') 
Example #3
Source File: sets.py    From SISideBar with MIT License 6 votes vote down vote up
def add_to_set_members():
    selection = cmds.ls(sl=True)
    
    if selection:
        setCount = 0
        for node in selection:
            if cmds.nodeType(node) != 'objectSet':
                continue
            for sel in selection:
                if sel == node:
                    continue
                try:
                    cmds.sets(sel, add=node)
                except Exception as e:
                    print e.message
            setCount += 1
        if setCount == 0:
            cmds.confirmDialog( title='Error',message='Please select set_node')

#選択セットのノード、コンポーネントを削除 
Example #4
Source File: dpSelectAllControls.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def dpMain(self, *args):
        """ Main function.
            Check existen nodes and call the scripted function.
        """
        callAction = False
        self.allGrp = self.dpFindAllGrpBySelection()
        if self.allGrp:
            callAction = True
        else:
            allGrpList = self.dpCountAllGrp()
            if allGrpList:
                if len(allGrpList) > 1:
                    self.allGrp = cmds.confirmDialog(title=self.langDic[self.langName]["m166_selAllControls"], message=self.langDic[self.langName]["m168_wichAllGrp"], button=allGrpList)
                else:
                    self.allGrp = self.dpCheckAllGrp(self.allGrp)
                if self.allGrp:
                    callAction = True
                else:
                    self.allGrp = self.dpFindAllGrp()
                    if self.allGrp:
                        callAction = True
        if callAction:
            self.dpSelectAllCtrls(self.allGrp)
        else:
            mel.eval("warning \""+self.langDic[self.langName]["e019_notFoundAllGrp"]+"\";") 
Example #5
Source File: weight_transfer_multiple.py    From SIWeightEditor with MIT License 6 votes vote down vote up
def stock_copy_mesh(self):
        hl_node = cmds.ls(hl=True, l=True)
        sel_node = cmds.ls(sl=True, l=True)
        temp_copy_mesh = common.search_polygon_mesh(hl_node+sel_node, fullPath=True)
        self.copy_mesh = []
        for node in temp_copy_mesh:
            skin_cluster = cmds.ls(cmds.listHistory(node), type='skinCluster')
            if skin_cluster:
                self.copy_mesh.append(node)
        
        if not self.copy_mesh:
            cmds.confirmDialog( title='Error',
                  message= self.msg02)
            return self.msg02
        return 'Set Copy Mesh :\n'+str(self.copy_mesh)
        #print 'copy mesh :',self.copy_mesh 
Example #6
Source File: uv.py    From SISideBar with MIT License 6 votes vote down vote up
def checkCurrentUV(self):
        if self.force:
            return True
        if cmds.polyEvaluate(self.mesh, uv=True, uvs=self.currentSet[0]) == 0:
            msg04 = lang.Lang(
                en=str(self.mesh)+' : Current UVSet ['+str(self.currentSet[0])+'] is empty.\nDo you skip this mesh?',
                ja=self.mesh+u' : 現在のUVSet ['+self.currentSet[0]+u'] が空です。\nこのメッシュをスキップしますか?'
            )   
            self.msg04 = msg04.output()
            self.skipMesh = cmds.confirmDialog(m=self.msg04, t='', b= [self.msg02, self.msg03], db=self.msg02, cb=self.msg03, icn='question',ds=self.msg03)
        else:
            return True#スキップしない
        if self.skipMesh == self.msg02:
            return False#スキップする
        else:
            return True#スキップしない 
Example #7
Source File: uv.py    From SISideBar with MIT License 6 votes vote down vote up
def ajustSelection(self):
        #選択したものからメッシュノードがあるものを取り出し。
        #何も選択されていなかったらシーン内のメッシュ全取得
        selection = cmds.ls(sl=True)
        #print len(selection)
        #print selection
        if self.popUpMsg:
            if len(selection) == 0:
                allMeshSel = cmds.confirmDialog(m=self.msg01, t='', b= [self.msg02, self.msg03], db=self.msg02, cb=self.msg03, icn='question',ds=self.msg03)
                #print allMeshSel
                if allMeshSel == self.msg02:
                    selection = cmds.ls(type='transform')
        else:
            if len(selection) == 0:
                #print 'process all of mesh'
                selection = cmds.ls(type='transform')
        #メッシュノードが存在したらリストに加える
        return [sel for sel in selection if common.search_polygon_mesh(sel)] 
Example #8
Source File: modeling.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def cehck_zero_poly_object(mesh=None, pop_msg=True):
    #mesh 入力メッシュ
    #pop_msg 探索結果を表示するかどうか
    if mesh == None:
        polyMeshes = common.search_polygon_mesh(cmds.ls(tr=True))
    else:
        polyMeshes = common.search_polygon_mesh(mesh)
    zeroPolyObj = []
    if polyMeshes == None:
        if pop_msg:
            cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
        return zeroPolyObj
    for p in polyMeshes:
        vtx = cmds.polyListComponentConversion(p, tv=True)
        if vtx == []:
            zeroPolyObj.append(p)
    if not pop_msg:
        return zeroPolyObj
    if zeroPolyObj == []:
        cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
    else:
        msg = 'Zero Polygon Object Count : '+str(len(zeroPolyObj))
        for p in zeroPolyObj:
            msg+='\n[ '+p+' ]'
        cmds.confirmDialog( title="Check",message=msg )
        cmds.select(zeroPolyObj, r=True)
    return zeroPolyObj
    
#スキニングを保ったままメッシュマージするクラス 
Example #9
Source File: ml_controlLibrary.py    From ml_tools with MIT License 5 votes vote down vote up
def ui():
    '''Launch the UI
    '''
    if not os.path.exists(REPOSITORY_PATH):
        result = mc.confirmDialog( title='Control Repository Not Found', message='Create a repository directory?',
                                   button=['Create','Cancel'], defaultButton='Cancel', cancelButton='Cancel', dismissString='Cancel' )

        if result != 'Create':
            return None

        os.mkdir(REPOSITORY_PATH)

    win = ControlLibraryUI()
    win.buildMainLayout()
    win.finish() 
Example #10
Source File: maya_PasteFromExternal.py    From OD_CopyPasteExternal with Apache License 2.0 5 votes vote down vote up
def fn_loadObjectFromTextfile():
    global importedObj
    importedObj.loaded_data = []
    if not os.path.exists(importFilename):
        print "Cant find file"
        cmds.confirmDialog(title='Error:', message='Cant find file:\n' + importFilename,button='Ok')
        return False
    else:
        f = open(importFilename)
        importedObj.loaded_data = f.readlines()
        f.close()
        return True 
Example #11
Source File: menu_loader.py    From mGui with MIT License 5 votes vote down vote up
def regular(*_, **__):
    print cmds.confirmDialog(title='mGui', message="Menus commands can be loaded as fully qualified path names, "
                                                   "like <b>mGui.examples.menu_loader.regular</b>", button="Cool!") 
Example #12
Source File: menu_loader.py    From mGui with MIT License 5 votes vote down vote up
def about(*_, **__):
    print cmds.confirmDialog(title='mGui', message="This is function was loaded from a yaml file", button="Wow!") 
Example #13
Source File: sets.py    From SISideBar with MIT License 5 votes vote down vote up
def remove_set_members():
    selection = cmds.ls(sl=True)
    if selection:
        setCount = 0
        for node in selection:
            if cmds.nodeType(node) != 'objectSet':
                continue
            setMembers = cmds.sets(node, int=node)
            for removeNode in selection:
                if removeNode == node:
                    continue
                try:
                    print 'Remove from set :', node, ': Object :', removeNode
                    cmds.sets(removeNode, rm=node)
                except:
                    pass
            setCount += 1
        if setCount == 0:
            cmds.confirmDialog( title='Error',message='Please select set_node') 
Example #14
Source File: playblast.py    From dpa-pipe with MIT License 5 votes vote down vote up
def playblast_dialog():
  # Creates a dialog prompt to determine if the user wishes to create a playblast
  #response = cmds.confirmDialog( title='Playblast', message='Are you SURE you want to create a new playblast?', button=['Yes','No'], defaultButton='No', cancelButton='No', dismissString='No' )
  #if response == 'Yes':
  floatUI() 
Example #15
Source File: dpTargetMirror.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def dpCheckGeometry(self, item, *args):
        isGeometry = False
        if item:
            if cmds.objExists(item):
                childList = cmds.listRelatives(item, children=True)
                if childList:
                    try:
                        itemType = cmds.objectType(childList[0])
                        if itemType == "mesh" or itemType == "nurbsSurface" or itemType == "subdiv":
                            if cmds.checkBox(self.checkHistoryCB, query=True, value=True):
                                historyList = cmds.listHistory(childList[0])
                                if len(historyList) > 1:
                                    dialogReturn = cmds.confirmDialog(title=self.langDic[self.langName]["i159_historyFound"], message=self.langDic[self.langName]["i160_historyDesc"]+"\n\n"+item+"\n\n"+self.langDic[self.langName]["i161_historyMessage"], button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No')
                                    if dialogReturn == "Yes":
                                        isGeometry = True
                                else:
                                    isGeometry = True
                            else:
                                isGeometry = True
                        else:
                            mel.eval("warning \""+item+" "+self.langDic[self.langName]["i058_notGeo"]+"\";")
                    except:
                        mel.eval("warning \""+self.langDic[self.langName]["i163_sameName"]+" "+item+"\";")
                else:
                    mel.eval("warning \""+self.langDic[self.langName]["i059_selTransform"]+" "+item+" "+self.langDic[self.langName]["i060_shapePlease"]+"\";")
            else:
                mel.eval("warning \""+item+" "+self.langDic[self.langName]["i061_notExists"]+"\";")
        else:
            mel.eval("warning \""+self.langDic[self.langName]["i062_notFound"]+" "+item+"\";")
        return isGeometry 
Example #16
Source File: dpTranslator.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def dpTranslatorMain(self, *args):
        """ Open a serie of dialog boxes to get user input to mount a new language json dictionary.
            We show a window to translate step by step.
        """
        # give info:
        greetingsDialog = cmds.confirmDialog(
                                            title=self.langDic[self.langName]['t000_translator'],
                                            message=self.langDic[self.langName]['t001_greeting'],
                                            button=[self.langDic[self.langName]['i131_ok'], self.langDic[self.langName]['i132_cancel']],
                                            defaultButton=self.langDic[self.langName]['i131_ok'],
                                            cancelButton=self.langDic[self.langName]['i132_cancel'],
                                            dismissString=self.langDic[self.langName]['i132_cancel'])
        if greetingsDialog == self.langDic[self.langName]['i131_ok']:
            self.dpGetUserInfoUI() 
Example #17
Source File: dpCar.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def getUserDetail(opt1, opt2, cancel, userMessage):
    """ Ask user the detail level we'll create the guides by a confirm dialog box window.
        Options:
            Simple
            Complete
        Returns the user choose option or None if canceled.
    """
    result = cmds.confirmDialog(title=CLASS_NAME, message=userMessage, button=[opt1, opt2, cancel], defaultButton=opt2, cancelButton=cancel, dismissString=cancel)
    return result 
Example #18
Source File: dpBike.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def getUserDetail(opt1, opt2, cancel, userMessage):
    """ Ask user the detail level we'll create the guides by a confirm dialog box window.
        Options:
            Simple
            Complete
        Returns the user choose option or None if canceled.
    """
    result = cmds.confirmDialog(title=CLASS_NAME, message=userMessage, button=[opt1, opt2, cancel], defaultButton=opt2, cancelButton=cancel, dismissString=cancel)
    return result 
Example #19
Source File: dpTweaks.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def getUserDetail(opt1, opt2, cancel, default, userMessage):
    """ Ask user the detail level we'll create the guides by a confirm dialog box window.
        Options:
            Simple
            Complete
        Returns the user choose option or None if canceled.
    """
    result = cmds.confirmDialog(title=CLASS_NAME, message=userMessage, button=[opt1, opt2, cancel], defaultButton=default, cancelButton=cancel, dismissString=cancel)
    return result 
Example #20
Source File: dpQuadruped.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def getUserDetail(opt1, opt2, cancel, userMessage):
    """ Ask user the detail level we'll create the guides by a confirm dialog box window.
        Options:
            Simple
            Complete
        Returns the user choose option or None if canceled.
    """
    result = cmds.confirmDialog(title=CLASS_NAME, message=userMessage, button=[opt1, opt2, cancel], defaultButton=opt2, cancelButton=cancel, dismissString=cancel)
    return result 
Example #21
Source File: dpBiped.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def getUserDetail(opt1, opt2, cancel, userMessage):
    """ Ask user the detail level we'll create the guides by a confirm dialog box window.
        Options:
            Simple
            Complete
        Returns the user choose option or None if canceled.
    """
    result = cmds.confirmDialog(title=CLASS_NAME, message=userMessage, button=[opt1, opt2, cancel], defaultButton=opt2, cancelButton=cancel, dismissString=cancel)
    return result 
Example #22
Source File: weight_transfer_multiple.py    From SIWeightEditor with MIT License 4 votes vote down vote up
def transfer_weight_multiple(self):
        global siweighteditor
        from . import siweighteditor
        
        if self.copy_mesh == []:
            cmds.confirmDialog( title='Error',
                  message= self.msg01)
            return self.msg01
            
        if not self.check_copy_mesh():
            cmds.confirmDialog( title='Error',
                  message= self.msg05)
            return self.msg05
            
        self.transfer_mesh = cmds.filterExpand(sm=12) or []
        self.transfer_comp = cmds.ls(sl=True, type='float3')
        self.hl_nodes = cmds.ls(hl=True, l=True, tr=True)
        if self.transfer_comp:
            self.store_current_vtxArray()
            self.pre_transfer_for_noskin_comp()
        #print 'transfered mesh :', self.transfer_mesh
        #メッシュ選択がなければ抜ける
        if not self.transfer_mesh and not self.transfer_comp:
            cmds.confirmDialog( title='Error',
                  message= self.msg06)
            return self.msg06
            
        #ウェイト付きで複製する
        self.dup_objs = self.dup_polygon_mesh()
        #一旦全部マージして転送もとオブジェクトにする
        self.marged_mesh = modeling.MeshMarge().main(self.dup_objs)
        #全てのインフルエンスを取得しておく
        self.store_all_influence()
        
        #オブジェクト、コンポーネント毎に転送実行
        if self.transfer_mesh:
            self.all_transfer()
        if self.transfer_comp:
            self.part_transfer()
            
        self.delete_sub_objects()
        
        cmds.select(self.transfer_mesh+self.hl_nodes+self.transfer_comp)
        
        return 'Transfer Weight to :\n'+str(self.transfer_mesh) 
Example #23
Source File: freeze.py    From SIWeightEditor with MIT License 4 votes vote down vote up
def main(mesh=None, pop_zero_poly=False):
    cmds.selectMode(o=True)
    #pop_zero_poly→ゼロポリゴンメッシュを発見した場合に警告メッセージを出すかどうか
    msg01 = lang.Lang(
        en='There is a zero polygon object : ',
        ja=u'ゼロポリゴンのメッシュが存在します : ')   
    msg02 = lang.Lang(
        en='As it is in selected state, please process accordingly\n(Recommended to delete)',
        ja=u'選択状態になっているので適宜処理してください \n(削除推奨)')   
    if mesh is None:
        selection = cmds.ls(sl=True)
        selection_l = cmds.ls(sl=True, l=True)
    else:
        selection = mesh
        selection_l = cmds.ls(mesh, l=True)
    zero_mesh = modeling.cehck_zero_poly_object(mesh=selection, pop_msg=False)
    #リストタイプじゃなかったらリストに変換する
    if not isinstance(selection, list):
        temp = selection
        selection = []
        selection.append(temp)
    clusterCopy = modeling.ClusterCopy()
    engine = 'maya'
    for node, node_l in zip(selection, selection_l):
        if node in zero_mesh:
            print 'Skip Zero Triangle Mesh :', node
            continue
        #メッシュノードを含むオブジェクトのみ処理する。
        meshnode = cmds.listRelatives(node_l, s=True, pa=True, type='mesh', fullPath=True)
        if meshnode:
            defCls = clusterCopy.copy(node)
            bs_dict = store_blend_shape(node)
            #ブレンドシェイプを保存
            copyWeight(node_l, engine=engine )
            freezeModeling(node_l, engine=engine )
            if defCls:
                clusterCopy.paste(node)
            set_blend_shape(node, bs_dict)
    cmds.select(cl=True)
    for s in selection:
        try:
            cmds.select(s, add=True)
        except Exception as e:
            print e.message
    if zero_mesh and pop_zero_poly:
        msg = msg01.output()+str(len(zero_mesh))
        msg += '\n'+msg02.output()
        for p in zero_mesh:
            msg+='\n[ '+p+' ]'
        cmds.confirmDialog( title="Warning", message=msg )
        cmds.select(zero_mesh, r=True)
        
#ブレンドシェイプ情報を保存 
Example #24
Source File: weight.py    From SIWeightEditor with MIT License 4 votes vote down vote up
def toggle_mute_skinning():
    msg01 = lang.Lang(
        en='No mesh selection.\nWould you like to process all of mesh in this scene?.',
        ja=u'選択メッシュがありません。\nシーン内のすべてのメッシュを処理しますか?').output()
    msg02 = lang.Lang(en='Yes', ja=u'はい').output()
    msg03 = lang.Lang(en='No', ja=u'いいえ').output()
    msg04 = lang.Lang(
        en='Skinning is disabled',
        ja=u'スキニングは無効になりました') .output()
    msg05 = lang.Lang(
        en='Skinning is enabled',
        ja=u'スキニングが有効になりました') .output()
    
    cmds.selectMode(o=True)
    objects = cmds.ls(sl=True, l=True)
    ad_node = []
    
    for node in objects:
        children = cmds.ls(cmds.listRelatives(node, ad=True, f=True), type ='transform')
        ad_node += [node]+children
    #print len(ad_node)
    objects = set(ad_node)
    #print len(objects)
    
    if not objects:
        all_mesh = cmds.confirmDialog(m=msg01, t='', b= [msg02, msg03], db=msg02, cb=msg03, icn='question',ds=msg03)
        if all_mesh == msg02:
            objects = cmds.ls(type='transform')
            
    if not objects:
        return
        
    mute_flag = 1
    skin_list = []
    for node in objects:
        skin = cmds.ls(cmds.listHistory(node), type='skinCluster')
        if not skin:
            continue
        skin_list.append(skin)
        if cmds.getAttr(skin[0]+'.envelope') > 0:
            mute_flag = 0
    for skin in skin_list:
        cmds.setAttr(skin[0]+'.envelope', mute_flag)
    if mute_flag == 0:
        cmds.confirmDialog(m=msg04)
    if mute_flag == 1:
        cmds.confirmDialog(m=msg05) 
Example #25
Source File: dpAutoRig.py    From dpAutoRigSystem with GNU General Public License v2.0 4 votes vote down vote up
def skinFromUI(self, *args):
        """ Skin the geometries using the joints, reading from UI the selected items of the textScrollLists or getting all items if nothing selected.
        """
        # get joints to be skinned:
        uiJointSkinList = cmds.textScrollList( self.allUIs["jntTextScrollLayout"], query=True, selectItem=True)
        if not uiJointSkinList:
            uiJointSkinList = cmds.textScrollList( self.allUIs["jntTextScrollLayout"], query=True, allItems=True)
        
        # check if all items in jointSkinList exists, then if not, show dialog box to skinWithoutNotExisting or Cancel
        jointSkinList, jointNotExistingList = [], []
        for item in uiJointSkinList:
            if cmds.objExists(item):
                jointSkinList.append(item)
            else:
                jointNotExistingList.append(item)
        if jointNotExistingList:
            notExistingJointMessage = self.langDic[self.langName]['i069_notSkinJoint'] +"\n\n"+ ", ".join(str(jntNotExitst) for jntNotExitst in jointNotExistingList) +"\n\n"+ self.langDic[self.langName]['i070_continueSkin']
            btYes = self.langDic[self.langName]['i071_yes']
            btNo = self.langDic[self.langName]['i072_no']
            confirmSkinning = cmds.confirmDialog(title='Confirm Skinning', message=notExistingJointMessage, button=[btYes,btNo], defaultButton=btYes, cancelButton=btNo, dismissString=btNo)
            if confirmSkinning == btNo:
                jointSkinList = None
        
        # get geometries to be skinned:
        geomSkinList = cmds.textScrollList( self.allUIs["modelsTextScrollLayout"], query=True, selectItem=True)
        if not geomSkinList:
            geomSkinList = cmds.textScrollList( self.allUIs["modelsTextScrollLayout"], query=True, allItems=True)
        
        # check if we have repeated listed geometries in case of the user choose to not display long names:
        if self.validateGeoList(geomSkinList):
            if jointSkinList and geomSkinList:
                for geomSkin in geomSkinList:
                    if (args[0] == "Add"):
                        cmds.skinCluster(geomSkin, edit=True, ai=jointSkinList, toSelectedBones=True, removeUnusedInfluence=False, lockWeights=True, wt=0.0)
                    elif (args[0] == "Remove"):
                        cmds.skinCluster(geomSkin, edit=True, ri=jointSkinList, toSelectedBones=True)
                    else:
                        baseName = utils.extractSuffix(geomSkin)
                        skinClusterName = baseName+"_SC"
                        if "|" in skinClusterName:
                            skinClusterName = skinClusterName[skinClusterName.rfind("|")+1:]
                        cmds.skinCluster(jointSkinList, geomSkin, toSelectedBones=True, dropoffRate=4.0, maximumInfluences=3, skinMethod=0, normalizeWeights=1, removeUnusedInfluence=False, name=skinClusterName)
                print self.langDic[self.langName]['i077_skinned'] + ', '.join(geomSkinList),
        else:
            print self.langDic[self.langName]['i029_skinNothing'],

    ###################### End: Skinning. 
Example #26
Source File: ml_controlLibrary.py    From ml_tools with MIT License 4 votes vote down vote up
def promptExportControl(*args):
    '''Export selection, prompt for name, and create icon as well.
    '''

    sel = mc.ls(sl=True)

    assert sel, 'Select a control curve(s) to export.'

    for each in sel:
        if mc.nodeType(each) == 'nurbsCurve':
            continue
        shapes = mc.listRelatives(each, shapes=True, type='nurbsCurve')
        assert shapes, '{} is not a nurbsCurve'.format(each)

    result = mc.promptDialog(
        title='Export Control Curve',
        message='Enter Name:',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel')

    if result != 'OK':
        return

    ctrlName = mc.promptDialog(query=True, text=True)
    ctrlName = ''.join(x if x.isalnum() else '_' for x in ctrlName)

    if os.path.exists(controlFilePath(ctrlName)):
        result = mc.confirmDialog(title='Control Exists',
                                  message='A control of this name already exists.',
                                  button=['Overwrite','Cancel'],
                                  defaultButton='Cancel',
                                  cancelButton='Cancel',
                                  dismissString='Cancel'
                                  )
        if result != 'Overwrite':
            return

    ctrl = exportControl(sel, ctrlName)

    strokes = mc.ls(type='stroke')

    #create the icon
    mc.ResetTemplateBrush()
    brush = mc.getDefaultBrush()
    mc.setAttr(brush+'.screenspaceWidth', 1)
    mc.setAttr(brush+'.distanceScaling', 0.01)
    mc.setAttr(brush+'.color1', 0.1, 0.65, 1, type='double3')

    mc.select(ctrl)
    mc.AttachBrushToCurves(ctrl)
    image = utl.renderShelfIcon(name=ctrlName, width=64, height=64)

    imagePath = os.path.join(REPOSITORY_PATH, os.path.basename(image))
    shutil.move(image, imagePath)

    #delete new strokes.
    newStrokes = [x for x in mc.ls(type='stroke') if x not in strokes]
    for each in newStrokes:
        mc.delete(mc.listRelatives(each, parent=True, pa=True)) 
Example #27
Source File: maya_ExportToExternal.py    From OD_CopyPasteExternal with Apache License 2.0 4 votes vote down vote up
def fn_getObjectData():
    global exportedObj
    curSel = cmds.ls(selection = True)
    if len(curSel) > 0:
        exportedObj.name = curSel[0]
        exportedObj.vertexCount = cmds.polyEvaluate(exportedObj.name, vertex = True)
        exportedObj.polyCount = cmds.polyEvaluate(exportedObj.name, face = True)

        exportedObj.vertices = []
        exportedObj.polys = []
        exportedObj.weightMap = []

        for v in range(0,exportedObj.vertexCount - 0, 1):
            vStr = exportedObj.name + ".vtx[" + str(v) + "]"
            vPos = cmds.xform(vStr, q= True,  os = True, translation = True)
            exportedObj.vertices.append(vPos)
            try:
                w = cmds.polyColorPerVertex(vStr, q = True, r = True)[0]
            except:
                w = -1

            exportedObj.weightMap.append(w)


        for f in range(0,exportedObj.polyCount - 0, 1):
            vStr = exportedObj.name + ".f[" + str(f) + "]"
            cmds.select(vStr, replace = True)
            verts = cmds.polyInfo(fv = True)
            vertsTemp = verts[0].split(":")
            vertsTemp = vertsTemp[1].split(" ")
            vList = []
            for fv in vertsTemp:
                if fv.strip() != "":
                    vList.append(int(fv))
            exportedObj.polys.append(vList)

        cmds.select(curSel, replace = True)
        return True
    else:
        cmds.confirmDialog(title='Error:', message='No object selected!',button='Ok')
        print "Nothing selected!"
        return False 
Example #28
Source File: setup.py    From SISideBar with MIT License 4 votes vote down vote up
def open_scene(mime_data):
    url_list = mime_data.urls()
    ext_dict = {'.ma':'mayaAscii', '.mb':'mayaBinary'}
    for file in url_list:
        file = file.toString().replace('file://', '')
        file_name, ext = os.path.splitext(file)
        if not ext.lower() in ext_dict.keys():
            continue
        #保存するかどうか
        msg05 = lang.Lang(
            en='untitled scene',
            ja=u'無題のシーン'
        )
        msg05 = msg05.output()
        scene_path = cmds.file(q=True, sceneName=True)
        if  scene_path == '':
            scene_path = msg05
        msg01 = lang.Lang(
            en='Save changes to '+scene_path+'?',
            ja= scene_path+u'への変更を保存しますか?'
        )   
        msg02 = lang.Lang(
            en='Save',
            ja=u'保存'
        )
        msg03 = lang.Lang(
            en="Don't Save",
            ja=u'保存しない'
        )
        msg04 = lang.Lang(
            en='Cancel',
            ja=u'キャンセル'
        )
        msg01 = msg01.output()
        msg02 = msg02.output()
        msg03 = msg03.output()
        msg04 = msg04.output()
        fileModified = cmds.file(q=True, modified=True)
        if fileModified:
            print 'modefie'
            proc = cmds.confirmDialog(m=msg01, t='', b= [msg02, msg03, msg04], db=msg02, cb=msg04, icn='question',ds=msg03)
            if proc == msg04:
                return
            elif proc == msg03:
                pass
            elif proc == msg02:
                if scene_path == msg05:
                    mel.eval("SaveSceneAs;")
                else:
                    cmds.file(save=True)
        
        if file.startswith('/'):
            file_path = file[1:]
        else:
            file_path = '//'+file[:]
        cmds.file(file_path, iv=True, f=True, o=True, typ=ext_dict[ext])
        mel.eval('addRecentFile("'+file_path+'", "'+ext_dict[ext]+'")') 
Example #29
Source File: freeze.py    From SISideBar with MIT License 4 votes vote down vote up
def main(mesh=None, pop_zero_poly=False):
    cmds.selectMode(o=True)
    #pop_zero_poly→ゼロポリゴンメッシュを発見した場合に警告メッセージを出すかどうか
    msg01 = lang.Lang(
        en='There is a zero polygon object : ',
        ja=u'ゼロポリゴンのメッシュが存在します : ')   
    msg02 = lang.Lang(
        en='As it is in selected state, please process accordingly\n(Recommended to delete)',
        ja=u'選択状態になっているので適宜処理してください \n(削除推奨)')   
    if mesh is None:
        selection = cmds.ls(sl=True)
        selection_l = cmds.ls(sl=True, l=True)
    else:
        selection = mesh
        selection_l = cmds.ls(mesh, l=True)
    zero_mesh = modeling.cehck_zero_poly_object(mesh=selection, pop_msg=False)
    #リストタイプじゃなかったらリストに変換する
    if not isinstance(selection, list):
        temp = selection
        selection = []
        selection.append(temp)
    clusterCopy = modeling.ClusterCopy()
    engine = 'maya'
    for node, node_l in zip(selection, selection_l):
        if node in zero_mesh:
            print 'Skip Zero Triangle Mesh :', node
            continue
        #メッシュノードを含むオブジェクトのみ処理する。
        meshnode = cmds.listRelatives(node_l, s=True, pa=True, type='mesh', fullPath=True)
        if meshnode:
            defCls = clusterCopy.copy(node)
            bs_dict = store_blend_shape(node)
            #ブレンドシェイプを保存
            copyWeight(node_l, engine=engine )
            freezeModeling(node_l, engine=engine )
            if defCls:
                clusterCopy.paste(node)
            set_blend_shape(node, bs_dict)
    cmds.select(cl=True)
    for s in selection:
        try:
            cmds.select(s, add=True)
        except Exception as e:
            print e.message
    if zero_mesh and pop_zero_poly:
        msg = msg01.output()+str(len(zero_mesh))
        msg += '\n'+msg02.output()
        for p in zero_mesh:
            msg+='\n[ '+p+' ]'
        cmds.confirmDialog( title="Warning", message=msg )
        cmds.select(zero_mesh, r=True)
        
#ブレンドシェイプ情報を保存 
Example #30
Source File: weight.py    From SISideBar with MIT License 4 votes vote down vote up
def toggle_mute_skinning():
    msg01 = lang.Lang(
        en='No mesh selection.\nWould you like to process all of mesh in this scene?.',
        ja=u'選択メッシュがありません。\nシーン内のすべてのメッシュを処理しますか?').output()
    msg02 = lang.Lang(en='Yes', ja=u'はい').output()
    msg03 = lang.Lang(en='No', ja=u'いいえ').output()
    msg04 = lang.Lang(
        en='Skinning is disabled',
        ja=u'スキニングは無効になりました') .output()
    msg05 = lang.Lang(
        en='Skinning is enabled',
        ja=u'スキニングが有効になりました') .output()
    
    cmds.selectMode(o=True)
    objects = cmds.ls(sl=True, l=True)
    ad_node = []
    
    for node in objects:
        children = cmds.ls(cmds.listRelatives(node, ad=True, f=True), type ='transform')
        ad_node += [node]+children
    #print len(ad_node)
    objects = set(ad_node)
    #print len(objects)
    
    if not objects:
        all_mesh = cmds.confirmDialog(m=msg01, t='', b= [msg02, msg03], db=msg02, cb=msg03, icn='question',ds=msg03)
        if all_mesh == msg02:
            objects = cmds.ls(type='transform')
            
    if not objects:
        return
        
    mute_flag = 1
    skin_list = []
    for node in objects:
        skin = cmds.ls(cmds.listHistory(node), type='skinCluster')
        if not skin:
            continue
        skin_list.append(skin)
        if cmds.getAttr(skin[0]+'.envelope') > 0:
            mute_flag = 0
    for skin in skin_list:
        cmds.setAttr(skin[0]+'.envelope', mute_flag)
    if mute_flag == 0:
        cmds.confirmDialog(m=msg04)
    if mute_flag == 1:
        cmds.confirmDialog(m=msg05)