Beispiel #1
0
def createBindPosePrompt(*args):
    selected = getSelected()
    if selected:
        root = selected[0]

        if cmds.objectType(root) != 'joint':
            cmds.warning(
                'Create Joint Pose Failed: Must select a joint hierarchy.')
            return
        else:
            result = cmds.promptDialog(title='Create Joint Pose'.format(root),
                                       message='Enter Name:',
                                       button=['OK', 'Cancel'],
                                       defaultButton='OK',
                                       cancelButton='Cancel',
                                       dismissString='Cancel')

            if result == 'OK':
                name = cmds.promptDialog(query=True, text=True)
                if not name:
                    cmds.warning(
                        'Create Joint Pose Failed: Must specify a name.')
                    return
                else:
                    createBindPose(root, name)
            return
Beispiel #2
0
def make_geo_layer(geos):
    if not geos:
        return False
    print('// make_geo_layer(geos)->')
    print(geos)
    geos = mklist(geos)
    # query user for input
    answer = mc.promptDialog(title='Sharc Question',
                             message='Enter name for new geomtry matte render layer.',
                             text='NameMe_Matte')
    print('// make_geo_layer:answer='+answer)
    if answer == 'dismiss':
        return False
    else:
        mc.promptDialog(q=1)
    # create a render layer to store our work in
    print('// make_geo_layer:geos->')
    print(geos)
    rl = createRenderLayer(geos,name=answer,nr=1,mc=1)
    print('// made render layer ='+rl+'\n')
    # make a SG, material, name it, color it
    sg = sets(renderable=1,noSurfaceShader=1,empty=1,name='geo_shader_SG')
    mat = shadingNode('surfaceShader',asShader=1)
    mat.outColor >> sg.surfaceShader
    mat = rename(mat,'geo_shader')
    mat.setAttr('outColorR',1)
    mat.setAttr('outColorG',1)
    mat.setAttr('outColorB',1)
    # assign new shader to the geos
    for geo in geos:
        sets(sg,forceElement=geo)
        arnold_disable_all_aovs(rl)
    return True
Beispiel #3
0
def SundayDialogPromptVariableAndStayOpen(title, message, text, ok, close):
    result = cmds.promptDialog(title = title, message = message, text = text, button = [
        ok,
        close], defaultButton = ok, cancelButton = close, dismissString = close)
    if result != close:
        return cmds.promptDialog(query = True, text = True)
    return 0
Beispiel #4
0
def filterSelection():
    selection = cmds.ls(selection=True)
    if cmds.optionVar(exists='ka_filterSelectionLastFilter'):
        defaultFilter = cmds.optionVar(query='ka_filterSelectionLastFilter')
    else:
        defaultFilter = ''

    result = cmds.promptDialog(
        title='Filter Selection by Type',
        message='Type to Filter',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel',
        text=defaultFilter,
    )

    if result == 'OK':
        filter = cmds.promptDialog(query=True, text=True)
        cmds.optionVar(sv=('ka_filterSelectionLastFilter', filter))

        newSelection = []
        for each in selection:
            if cmds.nodeType(each) == filter:
                newSelection.append(each)

        if newSelection:
            cmds.select(newSelection)
        else:
            cmds.select(clear=True)
Beispiel #5
0
def run():
    selected = cmds.ls(sl=True)
    result = cmds.promptDialog(title='RenameGeo',
                               message='Enter Name',
                               button=['OK', 'Cancel'],
                               defaultButton='OK',
                               cancelButton='Cancel',
                               dismissString='Cancel')
    if result == 'OK':
        text = cmds.promptDialog(q=True, text=True)
        if '%d' not in text:
            cmds.rename(selected[0], text)
        else:
            for s in selected:
                """
                counter = 0
                found = False
                while(not found):
                    newname = text % counter
                    match = cmds.ls(newname)
                    if len(match) < 1 :
                        found = True
                        cmds.rename(s,newname)
                        print('%s -> %s' % (s,newname))
                    counter += 1
                """
                doRename(s, text, 'geo')
def Renameanim(posefile,*args):
    filename = os.path.basename(posefile).split('.')[0]
    dirname  = os.path.dirname(posefile)
    seltab   = mc.shelfTabLayout('Animation',q=1,st=1)
    AnimRename = mc.promptDialog(
                    title='AnimRename',
                    message='AnimRename:',
                    text = filename,
                    button=['OK', 'Cancel'],
                    defaultButton='OK',
                    cancelButton='Cancel',
                    dismissString='Cancel') 
    if AnimRename=='OK':   
        newanimname = mc.promptDialog (query=True, text=True)         
        renamanim= dirname+'/'+ newanimname+'.anim'       
        renamimag= dirname+'/'+ newanimname+'.bmp'
        animimg  = posefile.replace('.anim','.bmp')
        print animimg
        mc.sysFile(posefile,rename= renamanim)
        mc.sysFile(animimg,rename= renamimag)
        Refresh_UI(savepathini)
        print'Anim name changed succesfully'
    else:
        return
    mc.shelfTabLayout('Animation',e=1,st=seltab)    
Beispiel #7
0
	def prompt( self ):
		"""Aquire the information using a prompt dialog
		
		:return: prompted value if input was confirmed using confirmToken, or the cancelValue
			if cancelToken was pressed
		:note: tokens correspond to buttons
		:note: handles batch mode correctly"""
		if cmds.about( batch = 1 ):
			return super( Prompt, self ).prompt( )

		default_text = ( self.confirmDefault is not None and self.confirmDefault ) or ""

		tokens = [ self.confirmToken ]
		token_kwargs = { "db" : self.confirmToken }
		if self.cancelToken is not None:
			tokens.append( self.cancelToken )
			token_kwargs[ "cb" ] = self.cancelToken
		# END token preparation
		token_kwargs.update( self._kwargs )

		ret = cmds.promptDialog( t="Prompt", m = self.msg, b = tokens, text = default_text, **token_kwargs )

		if ret == self.cancelToken:
			return self.cancelDefault

		if ret == self.confirmToken:
			return cmds.promptDialog( q=1, text = 1 )

		return self.confirmDefault
Beispiel #8
0
def setCutGeometry(proxyList, cutGeo=[]):
    """
    Set the cut geometry for the specified proxy bounds objects
    @param proxyList: List of proxy objects to set cut geometry for.
    @type proxyList: list
    @param cutGeo: The cut geometry list to set for the specified proxy bounds objects. If empty, string dialog is provided.
    @type cutGeo: list
    """
    # Check Proxy List
    if not proxyList: return
    for proxy in proxyList:
        if not isProxyBound(proxy):
            raise Exception('Invalid proxy object "' + proxy + '"!')
        if not cmds.objExists(proxy + '.cutGeometry'):
            print('Adding "cutGeometry" attribute to proxy bounds object "' + proxy + '"')
            cutGeoAttr([proxy])

    # Check Cut Geometry List
    if not cutGeo:
        result = cmds.promptDialog(title='Set Cut Geometry',
                                 message='Cut Geometry:',
                                 button=['Set', 'Cancel'],
                                 defaultButton='Set',
                                 cancelButton='Cancel',
                                 dismissString='Cancel')

        if result == 'Set':
            cutGeo = cmds.promptDialog(q=True, text=True)
        if not cutGeo:
            print('No valid cut geometry list provided!')

    # Set Cut Geometry List
    for proxy in proxyList:
        cmds.setAttr(proxy + '.cutGeometry', str(cutGeo), type='string')
    def onAddRule(self, *args):

        # Obtain rule name.
        okStr = maya.stringTable['y_inputSpaceRulesUI.kColorMgtOK']
        cancelStr = maya.stringTable['y_inputSpaceRulesUI.kColorMgtCancel']

        result = cmds.promptDialog(
            title=maya.stringTable['y_inputSpaceRulesUI.kRuleDialogTitle'],
            message=maya.stringTable['y_inputSpaceRulesUI.kRuleDialogMsg'],
            button=[okStr, cancelStr],
            defaultButton=okStr,
            cancelButton=cancelStr,
            dismissString=cancelStr)

        if result != okStr:
            return

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

        # Create rule with match all pattern, 'exr' extension, and same color
        # space as default rule.
        rules = cmds.colorManagementFileRules(listRules=True)
        colorSpace = cmds.colorManagementFileRules(rules[0],
                                                   query=True,
                                                   colorSpace=True)

        cmds.colorManagementFileRules(add=text,
                                      pattern='*',
                                      extension='exr',
                                      colorSpace=colorSpace)

        self.appendRule(FilePathRule(name=text))
Beispiel #10
0
    def selectionToFile(self):

        #GET SELECTION
        selection = mc.ls(sl=True)

        #FILL CLASS ATTR
        self.createFromCurve(selection)

        #ASK THE NAME OF THE FORM
        result = mc.promptDialog(title='Save Curve Form ',
                                 message='Enter name of the form:',
                                 button=['OK', 'Cancel'],
                                 defaultButton='OK',
                                 cancelButton='Cancel',
                                 dismissString='Cancel')

        if (result == 'OK'):
            form = mc.promptDialog(query=True, text=True)
        else:
            return 0

        #SAVE CURVE
        self.toFile(form)
        self.printAttrs('toFileSelected', self.debug)
        return 1
Beispiel #11
0
def ui():
    result = cmds.promptDialog(
        title='Retime Animation Curves',
        message=('Enter new_frame/src_frame separated by a space.' +
                 '\n\nOn Frame X I want to see Frame Y = X/Y'),
        button=['Selected', 'Scene', 'Cancel'],
        defaultButton='Selected',
        cancelButton='Cancel',
        dismissString='Cancel')

    if result == 'Cancel':
        return

    text = cmds.promptDialog(query=True, text=True)
    print text
    time_filter = []
    value_pairs = text.split(' ')
    for value_pair in value_pairs:
        values = value_pair.split('/')
        pair = (float(values[0]), float(values[1]))
        time_filter.append(pair)

    if result == 'Selected':
        selected(time_filter)
    else:
        scene(time_filter)
Beispiel #12
0
    def _create_ui(self, node):
        result = cmds.promptDialog(title='Rename Object',
                                   message='Name after import for %s:' %
                                   node.name(),
                                   button=['Create Reference'])

        if result == 'Create Reference':
            imported_name = cmds.promptDialog(query=True, text=True)

            if not imported_name:
                response = cmds.confirmDialog(
                    title='Imported Name is Empty!',
                    message=
                    'Are you sure, you do NOT want to rename after import?',
                    button=['Yes', 'No'],
                    defaultButton='Yes',
                    cancelButton='No',
                    dismissString='No')

                if response == "No":
                    self._create_ui(node)

            else:
                # set the attr on the node, also create a safe string
                cmds.setAttr("%s.%s" % (node.name(), IMPORTABLE_ATTR_NAME),
                             urllib.quote(imported_name.replace(" ", "_"),
                                          safe=''),
                             type="string")
Beispiel #13
0
def remapGeometry():
	'''
	'''
	# Check Window
	win = 'skinClusterDataUI'
	if not mc.window(win,q=True,ex=True): return
	
	# Check SkinClusterData
	skinData = glTools.gl_global.glSkinClusterData
	if not skinData: return
	
	# Get User Selections
	geo = ''
	sel = mc.ls(sl=1,dag=True)
	if not sel:
		result = mc.promptDialog(title='Remap Geometry',message='Enter Name:',button=['Remap', 'Cancel'],defaultButton='Remap',cancelButton='Cancel',dismissString='Cancel')
		if result == 'Remap':
			geo = mc.promptDialog(q=True,text=True)
		else:
			print('User cancelled!')
			return
	else:
		geo = sel[0]
	
	# Remap Geometry
	skinData.remapGeometry(geometry=geo)
	
	# Refresh UI
	reloadUI()
	
	# Return Result
	return geo
Beispiel #14
0
 def setRootScale(self) :
 
     ''' Menu callback '''
     
     for rn in m.ls(type = 'peelSolveOptions') :
         for skelRoot in m.getAttr("peelSolveOptions.rootNodes") :
             if not m.objExists ( skelRoot ) :
                 m.warning("Could not find: " + str( skelRoot ))
                 continue
               
         attr = skelRoot + ".mocapScale"
         val = m.getAttr(attr) if m.objExists( attr ) else 1.0 
         ret = m.promptDialog(m="Scale for: " + str(skelRoot), text=str(val))
         if ret != 'Confirm' :
             print ret
             continue
          
         text = m.promptDialog(q=True, text=True)
         try :
             fval = float(text)
         except ValueError :
             m.warning("Invalid Value: " + str( text) )
             continue
             
            
         print "Setting scale attribute on: ", attr, "to", str(fval)
         if not m.objExists( attr ) :
             m.addAttr( skelRoot, sn='ms', ln='mocapScale', at='float')
             m.setAttr( attr, keyable=True)
         m.setAttr( attr, fval)
Beispiel #15
0
def SLiBDialogPromptVariableAndStayOpen(title, message, text, ok, close):
    result = cmds.promptDialog(title = title, message = message, text = text, button = [
        ok,
        close], defaultButton = ok, cancelButton = close, dismissString = close)
    if result != close:
        return cmds.promptDialog(query = True, text = True)
    return 0
Beispiel #16
0
def StripAndPublishComponent(component):
    """Prior to publishing a guide component, save a temp version and strip it of locked nodes."""
    
    if not cmds.objExists('rig_%s_guide' % component):
        rigUtils.log('Object not found: rig_%s_guide' % component, 'e')
        return

    prompt = cmds.promptDialog(m='Enter comment', b=['OK', 'Cancel'], cb='Cancel', db='OK', t='Enter Comment')
    if prompt == 'Cancel': return
    comment = cmds.promptDialog(q=True, tx=True)

    tmp = tempfile.mkstemp('.ma')[1]
    rigUtils.log('Saving temp file for %s: %s' % (component, tmp))
    cmds.file(rn=tmp)
    cmds.file(s=True, f=True, typ='mayaAscii')

    rigUtils.log('Removing lockNode commands from temp file: %s' % tmp)

    tmp2    = tempfile.mkstemp('.ma')[1]
    fin     = open(tmp, 'r')
    fout    = open(tmp2, 'w')

    # remove lockNode commands from ma file
    for line in fin.readlines():
        if 'lockNode' in line: continue
        fout.write(line)

    fin.close()
    fout.close()

    publishComponentGuide(component, tmp2, comment)
Beispiel #17
0
def mkObjSlIndx():
    mkObjList = cmds.ls(sl=True)
    mkCreatVOP = "vray objectProperties add_single;"
    NameResult = cmds.promptDialog(title='Name of ObjectProperties node',
                                   message='Enter Name:',
                                   button=['OK', 'Cancel'],
                                   defaultButton='OK',
                                   cancelButton='Cancel',
                                   dismissString='Cancel')
    if NameResult == 'OK':
        mktext = cmds.promptDialog(query=True, text=True)
    IDResult = cmds.promptDialog(title='object ID number',
                                 message='Enter ID:',
                                 button=['OK', 'Cancel'],
                                 defaultButton='OK',
                                 cancelButton='Cancel',
                                 dismissString='Cancel')
    if IDResult == 'OK':
        mkID = cmds.promptDialog(query=True, text=True)
    mkID = int(mkID)
    if mkObjList == []:
        print "nothing selected"
    else:
        mkVOPlist = cmds.ls(type="VRayObjectProperties")
        if mktext + "VOP" in mkVOPlist:
            print "vop already created for this object"
        else:
            mel.eval(mkCreatVOP)
            mkrename = cmds.rename("vrayobjectproperties", mktext + "VOP")
            cmds.setAttr(mkrename + ".objectID", mkID)
            cmds.setAttr(mkrename + ".objectIDEnabled", 1)
Beispiel #18
0
def manual_bend_chain(controller, curves):
    """Create a stretchable and bendable chain of bones on a curve"""

    if not controller or not curves:
        selection = mc.ls(sl=True, fl=True)
        controller = selection[-1]
        curves = selection[:-1]

    # dialog box
    result = mc.promptDialog(
        title='Number of bones',
        message='Type the number of bones that you want on'
        ' your curve(s)',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel')

    if result == 'OK':
        bones_nbr = mc.promptDialog(query=True, text=True)

    else:
        mc.confirmDialog(title='Confirm',
                         message='You have to type a number of bone(s)',
                         button=['Yes'],
                         defaultButton='Yes')
        return

    bones_nbr = int(bones_nbr)

    for crv in curves:
        bend_chain(crv, controller, bones_nbr)
def checkin():
        print 'checkin'
        saveFile() # save the file before doing anything
        print 'save'
        filePath = cmds.file(q=True, sceneName=True)
        print 'filePath: '+filePath
        toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
        print 'toCheckin: '+toCheckin
        if amu.canCheckin(toCheckin):

                comment = 'Comment'
                commentPrompt = cmds.promptDialog(
                                    title='Comment',
                                    message='What changes did you make?',
                                    button=['OK','Cancel'],
                                    defaultButton='OK',
                                    dismissString='Cancel',
                                    sf = True)
                if commentPrompt == 'OK':
                    comment = cmds.promptDialog(query=True, text=True);
                else:
                    return
                amu.setComment(toCheckin, comment)
                dest = amu.getCheckinDest(toCheckin)

                saveFile()
                cmds.file(force=True, new=True) #open new file
                dest = amu.checkin(toCheckin) #checkin
        else:
                showFailDialog()
def saveInPreWindow(nClothShapeName,charNameTarget):
    """创建预设保存窗口,输入预设名,保存预设

    Description:
        在预设保存窗口拿到用户输入的预设名,若预设名符合要求则保存预设

    Arguments:
        nClothShapeName:布料节点名称
        charNameTarget:目标角色名

    Returns:
        无
    """
    result = cmds.promptDialog(title = "Save Preset", message = "Char Preset Name:", button = ["Save", "Cancel"],
                                defaultButton = "Save", cancelButton = "Cancel", dismissString = "Cancel")  #拿到用户所选择的按钮
    if result == "Save":
        presetName = cmds.promptDialog(query=True, text=True)
        #
        #对输入的预设名进行检查:
        #        1、检查该预设名是否合理(只能是英文字母,不能含有下划线等符号);
        #        2、检查预设名是否已经存在(maya自带该检查功能)
        #
        p = re.compile("^[A-Za-z]+$")  #正则表达式,匹配所有英文字母
        if not p.match(presetName):
            cmds.confirmDialog(title = "Warning", message = "Please Input Letters(a-z A-Z) Only!", button = "OK", defaultButton = "OK")
            saveInPreWindow(nClothShapeName,charNameTarget)  #递归调用,重新创建预设保存窗体
        else:
            cPresetName = presetName + "_" + charNameTarget
            savePresetP(nClothShapeName, cPresetName)
            return cPresetName    
Beispiel #21
0
 def chain_rig(self, arg=None):
     import ChainWork
     reload (ChainWork)
     result = cmds.promptDialog( 
                 title='Building a chainrig', 
                 message="Enter dimentions for chain - EG:", 
                 text="name, Y, 10", 
                 button=['Continue','Cancel'],
                 defaultButton='Continue', 
                 cancelButton='Cancel', 
                 dismissString='Cancel' )
     if result == 'Continue':
         resultInfo=cmds.promptDialog(q=1)
         if resultInfo:
             pass
         else:
             print "nothing collected"
         getInfo=resultInfo.split(', ')
         getDir=getInfo[1]
         mainName=getInfo[0]
         if getDir=="X":
             nrx=1
             nry=0
             nrz=0  
         if getDir=="Y":
             nrx=0
             nry=1
             nrz=0   
         if getDir=="Z":
             nrx=0
             nry=0
             nrz=1
         ControllerSize=int(getInfo[2])
         getClass=ChainWork.ChainRig(nrz, nry, nrx, mainName, ControllerSize) 
Beispiel #22
0
def changeRefPath():
    promptState = mc.promptDialog(title='Change Reference File Path',
                                  message='New Dir:',
                                  button=['OK', 'Cancel'],
                                  defaultButton='OK',
                                  cancelButton='Cancel',
                                  dismissString='Cancel')
    if promptState == 'OK':
        dirText = mc.promptDialog(q=True, text=True)

        if os.path.isdir(dirText):
            allRefNode = mc.ls(sl=True, type='reference')
            if not allRefNode:
                allRefNode = mc.ls(type='reference')

            if len(allRefNode) == 0:
                return

            for eachNode in allRefNode:
                try:
                    refNodeName = mc.referenceQuery(eachNode, rfn=True)
                except:
                    continue

                currentFileName = mc.referenceQuery(refNodeName, filename=True)
                baseName = os.path.basename(currentFileName)
                newFullName = os.path.join(dirText, baseName)
                mc.file(newFullName, loadReference=refNodeName)
def make_geo_layer(geos):
    if not geos:
        return False
    print('// make_geo_layer(geos)->')
    print(geos)
    geos = mklist(geos)
    # query user for input
    answer = mc.promptDialog(
        title='Sharc Question',
        message='Enter name for new geomtry matte render layer.',
        text='NameMe_Matte')
    print('// make_geo_layer:answer=' + answer)
    if answer == 'dismiss':
        return False
    else:
        mc.promptDialog(q=1)
    # create a render layer to store our work in
    print('// make_geo_layer:geos->')
    print(geos)
    rl = createRenderLayer(geos, name=answer, nr=1, mc=1)
    print('// made render layer =' + rl + '\n')
    # make a SG, material, name it, color it
    sg = sets(renderable=1, noSurfaceShader=1, empty=1, name='geo_shader_SG')
    mat = shadingNode('surfaceShader', asShader=1)
    mat.outColor >> sg.surfaceShader
    mat = rename(mat, 'geo_shader')
    mat.setAttr('outColorR', 1)
    mat.setAttr('outColorG', 1)
    mat.setAttr('outColorB', 1)
    # assign new shader to the geos
    for geo in geos:
        sets(sg, forceElement=geo)
        arnold_disable_all_aovs(rl)
    return True
Beispiel #24
0
def defaultButtonPush09(*args):
	Maximum = cmds.promptDialog(
					title = "Maximum shots of Episode",
					message = "(Total shot of Episode) Insert_number:",
					button = ["OK", "Cancel"],
					defaultButton = "OK",
					cancelButton = "Cancel",
					dismissString = "Cancel")
	if Maximum == "OK":
		text001 = cmds.promptDialog(query = True, text = True)
		Num = 0
	EPI = cmds.promptDialog(
					title = "Episode",
					message = "ep + insert number:",
					button = ["OK", "Cancel"],
					defaultButton = "OK",
					cancelButton = "Cancel",
					dismissString = "Cancel")
	if EPI == "OK":
		Episode = cmds.promptDialog(query = True, text = True)

		for x in range(1, int(text001)+1):
			Num = Num+1
			AnimCachePath = "I:/bubblebathbay/episodes/%s/%s_sh%.3d/FX/publish/fx/" %(Episode,Episode,int(Num))
			if os.path.exists(AnimCachePath):
				if len(os.listdir(AnimCachePath)) != 0:
					VersionFolder = [i for i in os.listdir(AnimCachePath) if i.startswith("v") and not i.endswith("-copy")]
					LatestVersion = reduce(lambda a,b: a if int(a.strip("v")) > int(b.strip("v")) else b ,VersionFolder)
					if len(os.listdir(AnimCachePath+LatestVersion))== 0:
						print(Episode+"sh%.3d" %int(Num))
				else:
					print(Episode+"sh%.3d Empty or not Required" %int(Num))
			else:
				print(Episode+"sh%.3d Empty or not Required" %int(Num))
def addVrayObjectIds(shapes=None):
    """ Add a vray_objectID attribute to selected meshes

    :param shapes: Shapes to apply the attribute to. If shapes is None it will get
                   the shapes related to the current selection.
    """
    if shapes is None:
        shapes = mc.ls(sl=1, s=1, dag=1, lf=1, o=1, long=True)

    if shapes:
        # Can only add objectIds to mesh, nurbsSurface so lets filter it
        shapes = mc.ls(shapes, type=("mesh", "nurbsSurface"))

    if shapes:
        result = mc.promptDialog(
            title="Object ID value",
            message="Object ID:",
            button=["OK", "Cancel"],
            defaultButton="OK",
            cancelButton="Cancel",
            dismissString="Cancel",
        )

        if result == "OK":
            value = int(mc.promptDialog(query=True, text=True))

            for shape in shapes:
                mc.vray("addAttributesFromGroup", shape, "vray_objectID", 1)
                mc.setAttr("{0}.{1}".format(shape, "vrayObjectID"), value)
Beispiel #26
0
def checkin():
    print 'checkin NEW'
    saveFile()  # save the file before doing anything
    print 'File saved'

    filePath = cmds.file(q=True, sceneName=True)
    toInstall = checkAssetType('rig')

    if facade.canCheckin(
            filePath) and saveGeo():  # objs must be saved before checkin
        print "Can check in."
        comment = 'Comment'
        commentPrompt = cmds.promptDialog(title='Comment',
                                          message='What changes did you make?',
                                          button=['OK', 'Cancel'],
                                          defaultButton='OK',
                                          dismissString='Cancel',
                                          sf=True)
        if commentPrompt == 'OK':
            comment = cmds.promptDialog(query=True, text=True)
            print "Comment is: " + comment
        else:
            return
        saveFile()  # One more save
        cmds.file(force=True, new=True)  # Open a new file.
        checkinDest = facade.checkin(
            filePath, comment,
            toInstall)  # checkin, install to stable directories.
    else:
        showFailDialog()
Beispiel #27
0
def newModule():
	# MODULE NAME
	result = mc.promptDialog(
	                title='New Module Name',
	                message='Enter Name:',
	                button=['OK', 'Cancel'],
	                defaultButton='OK',
	                cancelButton='Cancel',
	                dismissString='Cancel')
	
	if result == 'OK':
	        name = mc.promptDialog(query=True, text=True)
	else: return
	        
	filename = mc.fileDialog2(fileMode=1, caption="Select module File")[0]	        	
	
	modGrp = mc.group(em = 1, n = name)
	mc.parent(modGrp, 'modules') 
	
	mc.setAttr((addString('Name',modGrp)), name, type = "string")
	mc.setAttr((addString('Module_Path',modGrp)), filename, type = "string")	
	# GET THE SCRIPT OF THE MODULE
	print getModuleScript(name)
				
	launch()
Beispiel #28
0
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))
Beispiel #29
0
def getMeshDescriptor(node, grpNode, override=False, divider="GRP"):
    '''Gets mesh descriptor for GEO nodes.
    '''
    currentGrp = grpNode.rpartition("|")[2]
    currentNode = node.rpartition("|")[2]
    assetName, grp, versionAndNumber = currentGrp.partition(divider)
    geoName, geo, instanceNumber = currentNode.partition("GEO")
    meshDescriptor = currentNode.rpartition(":")[2].replace(assetName, "", 1).replace("_GEO%s" % instanceNumber, "", 1).rpartition("|")[2].rpartition("_")[2]
    if "CPS" in divider:
        meshDescriptor = currentNode
    result = "OK"
    
    if not override:
        result = cmds.promptDialog(
                title="Rename Mesh", 
                message='Enter mesh descriptor for "%s": ' % currentNode, text=meshDescriptor, 
                button=["OK", "OK To All", "Rename All", "Cancel", "Cancel All"],
                defaultButton="OK", cancelButton="Cancel", dismissString="Cancel"
                )
        if result == "OK":
            meshDescriptor = cmds.promptDialog(query=True, text=True)
        elif result == "OK To All":
            meshDescriptor = cmds.promptDialog(query=True, text=True)
            result = "OK"
            override = True
        elif result == "Rename All":
            meshDescriptor = cmds.promptDialog(query=True, text=True)
            override = True
        
    return result, meshDescriptor, override
def addVrayObjectIds(shapes=None):
    """ Add a vray_objectID attribute to selected meshes

    :param shapes: Shapes to apply the attribute to. If shapes is None it will get
                   the shapes related to the current selection.
    """
    if shapes is None:
        shapes = mc.ls(sl=1, s=1, dag=1, lf=1, o=1, long=True)

    if shapes:
        # Can only add objectIds to mesh, nurbsSurface so lets filter it
        shapes = mc.ls(shapes, type=("mesh", "nurbsSurface"))

    if shapes:
        result = mc.promptDialog(title='Object ID value',
                                 message='Object ID:',
                                 button=['OK', 'Cancel'],
                                 defaultButton='OK',
                                 cancelButton='Cancel',
                                 dismissString='Cancel')

        if result == 'OK':
            value = int(mc.promptDialog(query=True, text=True))

            for shape in shapes:
                mc.vray("addAttributesFromGroup", shape, "vray_objectID", 1)
                mc.setAttr("{0}.{1}".format(shape, 'vrayObjectID'), value)
Beispiel #31
0
def setAddGeometry(proxyList,addGeo=[]):
	'''
	Set the add geometry for the specified proxy bounds objects
	@param proxyList: List of proxy objects to set add geometry for.
	@type proxyList: list
	@param addGeo: The add geometry list to set for the specified proxy bounds objects. If empty, string dialog is provided.
	@type addGeo: list
	'''
	# Check Proxy List
	if not proxyList: return
	for proxy in proxyList:
		if not isProxyBound(proxy):
			raise Exception('Invalid proxy object "'+proxy+'"!')
		if not mc.objExists(proxy+'.addGeometry'):
			print('Adding "addGeometry" attribute to proxy bounds object "'+proxy+'"')
			addGeoAttr([proxy])
	
	# Check Add Geometry List
	if not addGeo:
		result = mc.promptDialog(	title='Set Add Geometry',
									message='Add Geometry:',
									button=['Set', 'Cancel'],
									defaultButton='Set',
									cancelButton='Cancel',
									dismissString='Cancel'	)
		
		if result == 'Set':
			addGeo = mc.promptDialog(q=True,text=True)
		if not addGeo:
			print('No valid add geometry list provided!')
	
	# Set Add Geometry List
	for proxy in proxyList:
		mc.setAttr(proxy+'.addGeometry',str(addGeo),type='string')
Beispiel #32
0
def selectByAttr(attr=''):
	'''
	Select nodes with the specified attribute
	@param attr: Attribute to use a for the selection filter
	@type attr: str
	'''
	# Check Attribute
	if not attr:
	
		result = mc.promptDialog(	title='Select By Attribute',
									message='Attribute:',
									button=['Select','Cancel'],
									defaultButton='Select',
									cancelButton='Cancel',
									dismissString='Cancel'	)
		
		if result == 'Select':
			attr = mc.promptDialog(q=True,text=True)	
		
		# Check Attribute
		if not attr: return
	
	# Select By Attribute
	sel = mc.ls('*.'+attr,o=True)
	
	# Return Result
	return sel
Beispiel #33
0
def uiFunc_process_preset_change(obj, optionMenu):
    val = optionMenu.getValue()

    if val == "Save Preset":
        result = mc.promptDialog(title='Save Preset',
                                 message='Preset Name:',
                                 button=['OK', 'Cancel'],
                                 defaultButton='OK',
                                 cancelButton='Cancel',
                                 dismissString='Cancel')

        if result == 'OK':
            text = mc.promptDialog(query=True, text=True)
            if mc.nodePreset(isValidName=text):
                mc.nodePreset(save=(obj, text))
                optionMenu.clear()

                optionMenu.append("Load Preset")
                for a in mc.nodePreset(list=obj):
                    optionMenu.append(a)
                optionMenu.append("---")
                optionMenu.append("Save Preset")

                optionMenu.setValue(text)
            else:
                print "Invalid name, try again"
                optionMenu.setValue("Load Preset")
    elif mc.nodePreset(isValidName=val):
        if mc.nodePreset(exists=(obj, val)):
            mc.nodePreset(load=(obj, optionMenu.getValue()))
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)
def Newtab(*args):
    sel_tab = mc.shelfTabLayout('tabs',q=1,st=1)
    crnt_tab= mc.shelfTabLayout(sel_tab,q=1,ca=1)
    Newtab = mc.promptDialog(
                    title='Create New Tab',
                    message='New Tab Name:',
                    button=['OK', 'Cancel'],
                    defaultButton='OK',
                    cancelButton='Cancel',
                    dismissString='Cancel')    
    if Newtab == 'OK':
        n_text = mc.promptDialog(query=True, text=True)
        if n_text == '':
            mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is not valid', button=['OK'] ,defaultButton='Yes')      
        else:
            if crnt_tab:
                for each in crnt_tab:
                    if each == n_text:
                        mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is already exists', button=['OK'] ,defaultButton='Yes')
                        return 
            #else:     
            if sel_tab == 'Animation':
                Nw_tab=savepathini+'Savepose/Animation/'+n_text+'/'
                mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Animation)
                mc.sysFile(Nw_tab, makeDir=True )
                     
            else:
                mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Poses)
                Nw_tab=savepathini+'Savepose/Poses/'+n_text+'/' 
                mc.sysFile(Nw_tab, makeDir=True )
            mc.shelfTabLayout(sel_tab,e=1,st=n_text)
Beispiel #36
0
def ui():
    result = cmds.promptDialog(
		title='Retime Animation Curves',
		message=('Enter new_frame/src_frame separated by a space.'+
                 '\n\nOn Frame X I want to see Frame Y = X/Y'),
		button=['Selected', 'Scene', 'Cancel'],
		defaultButton='Selected',
		cancelButton='Cancel',
		dismissString='Cancel')

    if result == 'Cancel':
        return
    
    text = cmds.promptDialog(query=True, text=True)
    print text
    time_filter=[]
    value_pairs = text.split(' ')
    for value_pair in value_pairs:
        values = value_pair.split('/')
        pair = (float(values[0]),float(values[1]))
        time_filter.append(pair)
    
    if result == 'Selected':
        selected(time_filter)
    else:
        scene(time_filter)
def Renamepose(read1,*args):
    filename = os.path.basename(read1).split('.')[0]
    print filename
    dirname  = os.path.dirname(read1)
    seltab   = mc.shelfTabLayout('Poses',q=1,st=1)
    PoseRename = mc.promptDialog(
                    title='PoseRename',
                    message='PoseRename:',
                    text = filename,
                    button=['OK', 'Cancel'],
                    defaultButton='OK',
                    cancelButton='Cancel',
                    dismissString='Cancel') 
    if PoseRename=='OK':   
        newposename = mc.promptDialog (query=True, text=True)         
        renampose= dirname+'/'+ newposename+'.anim'       
        renameimg= dirname+'/'+ newposename+'.bmp'
        read2=read1.replace('.anim','.bmp')
        mc.sysFile(read1,rename= renampose)
        mc.sysFile(read2,rename= renameimg)
        Refresh_UI(savepathini)
        print'Pose name changed successfully'
    else:
        return
    mc.shelfTabLayout('Poses',e=1,st=seltab)
Beispiel #38
0
    def prompt(self):
        """Aquire the information using a prompt dialog
		
		:return: prompted value if input was confirmed using confirmToken, or the cancelValue
			if cancelToken was pressed
		:note: tokens correspond to buttons
		:note: handles batch mode correctly"""
        if cmds.about(batch=1):
            return super(Prompt, self).prompt()

        default_text = (self.confirmDefault is not None
                        and self.confirmDefault) or ""

        tokens = [self.confirmToken]
        token_kwargs = {"db": self.confirmToken}
        if self.cancelToken is not None:
            tokens.append(self.cancelToken)
            token_kwargs["cb"] = self.cancelToken
        # END token preparation
        token_kwargs.update(self._kwargs)

        ret = cmds.promptDialog(t="Prompt",
                                m=self.msg,
                                b=tokens,
                                text=default_text,
                                **token_kwargs)

        if ret == self.cancelToken:
            return self.cancelDefault

        if ret == self.confirmToken:
            return cmds.promptDialog(q=1, text=1)

        return self.confirmDefault
Beispiel #39
0
def doSomething():
    # Preps the geo for export

    objectsToExport=[]
    objectsToExport=cmds.ls( selection=True )
    selected = cmds.sets(n="selectedGeo")


    #dialogue for file export name

    if objectsToExport:
        result = cmds.promptDialog(
                title='.ass export',
                message='Enter .ass seq filename:',
                button=['OK', 'Cancel'],
                defaultButton='OK',
                cancelButton='Cancel',
                dismissString='Cancel')
        
        if result == 'OK':
            #Removes the camera (so imagePlanes etc don't get exported with any .ass files accidentally)
            refsList=cmds.ls(type='reference')
            removeCamera(refsList)

            setRendererArnold()
            global fileName
            fileName = cmds.promptDialog(query=True, text=True)
            exportGeo()

            
        print fileName
        
    else:
        cmds.delete("selectedGeo")
        cmds.error( "Nothing is selected! Select geo to export as .ass" )
def dup_morphyHeadShape(headToDup = 'UprFocus'):
    _sl = mc.ls(sl=True)
    if mc.objExists('bs_grp'):
        mGroup  = cgmMeta.cgmObject('bs_grp')
    else:
        mGroup  = cgmMeta.cgmObject()
        mGroup.addAttr('cgmName','bs')
        mGroup.addAttr('cgmType','grp')
        mGroup.doName()
    mGroup.v = 0
    result = mc.promptDialog(title='blendshape Name',
                             message='Enter Name:',
                             button=['OK', 'Cancel'],
                             defaultButton='OK',
                             cancelButton='Cancel',
                             dismissString='Cancel')
    if result:
        newName = mc.promptDialog(query=True, text=True)
        _name = newName
        if mc.objExists(_name):
            log.warning("Deleting {0}".format(_name))
            mc.delete(_name)
        log.info(_name)
        newMesh = mc.duplicate(headToDup)
        mMesh = cgmMeta.cgmObject(newMesh[0])
        attributes.doSetLockHideKeyableAttr(mMesh.mNode,False,True,True)			    
        mMesh.rename(_name)
        mMesh.parent = mGroup
        mMesh.translate = [0,0,0]
        if _sl:mc.select(_sl)
        return True
    return False
Beispiel #41
0
def renameSelection():
	"""rename all the selected objects going 1 by 1"""
	sel = mn.ls( sl = True )
	for s in sel:
		s() #select
		mc.refresh()
		result = mc.promptDialog(
				title         = 'Rename Object ' + s.name,
				message       = 'Enter Name:',
				button        = ['OK', 'Cancel','Stop'],
				defaultButton = 'OK',
				tx            = s.name,
				cancelButton  = 'Cancel',
				dismissString = 'Cancel')
		if result == 'OK':
			text = mc.promptDialog(query=True, text=True)
			if '#' in text:
				similars = mn.ls( text.replace( '#', '*' ) )
				if not similars:
					similars = []
				s.name = text.replace( '#', str( len( similars ) ) )
			else:
				s.name = text
		if result == 'Stop':
			return
Beispiel #42
0
def newModule():
    # MODULE NAME
    result = mc.promptDialog(title='New Module Name',
                             message='Enter Name:',
                             button=['OK', 'Cancel'],
                             defaultButton='OK',
                             cancelButton='Cancel',
                             dismissString='Cancel')

    if result == 'OK':
        name = mc.promptDialog(query=True, text=True)
    else:
        return

    filename = mc.fileDialog2(fileMode=1, caption="Select module File")[0]

    modGrp = mc.group(em=1, n=name)
    mc.parent(modGrp, 'modules')

    mc.setAttr((addString('Name', modGrp)), name, type="string")
    mc.setAttr((addString('Module_Path', modGrp)), filename, type="string")
    # GET THE SCRIPT OF THE MODULE
    print getModuleScript(name)

    launch()
Beispiel #43
0
 def simpleTemplateEditorNewGrp(*args):
     currColChld = cmds.columnLayout(str(cmds.tabLayout(tabs1, q=1, st=1)),
                                     q=1,
                                     ca=1)
     curList = ""
     result = cmds.promptDialog(title='Attribute Group Name ',
                                message='Enter Group Name:',
                                button=['OK', 'Cancel'],
                                defaultButton='OK',
                                cancelButton='Cancel',
                                dismissString='Cancel')
     if result == 'OK':
         text = cmds.promptDialog(query=True, text=True)
         zz = ""
         for c in text:
             if c.isalnum() == True:
                 zz = zz + c
         text = zz
         for temp in currColChld:
             if cmds.textScrollList(temp, exists=True):
                 curList = temp
         selAttrs = cmds.textScrollList(curList, q=1, sii=True)
         if selAttrs == None:
             return
         selAttrs.sort(reverse=False)
         insertPt = selAttrs[0]
         if insertPt < 1:
             insertPt = 1
         cmds.textScrollList(curList,
                             e=1,
                             ap=[insertPt, (text + " (Group)")])
Beispiel #44
0
def changeLicence(*args):
    """
    """
    licenseKey = ""
    result = cmds.promptDialog(title='License Registration',
                               message='Enter License Key',
                               button=['ok', 'cancel'],
                               defaultButton='ok',
                               cancelButton='cancel',
                               dismissString='cancel')
    if result == 'ok':
        licenseKey = cmds.promptDialog(q=True, text=True)
    else:
        return

    licenseObj = License.License(licenseKey)
    validator = licenseObj.validate()
    if validator == 'Invalid':
        print("Invalid License")
        return
    elif validator == 'Expired':
        print("License Expired")
        return
    elif validator == 'Valid':
        License.License.writeLicense(licenseKey)
Beispiel #45
0
def infoButton(*args):
	cmds.promptDialog(
		title='Info',
		message='Info',
		button=['OK'],
		defaultButton='OK',
		dismissString='OK')
Beispiel #46
0
	def SetLights(self, *args):    
		#user input for which light rig
		result = cmds.promptDialog(
					title='Light Rig Name',
					message='Enter Name:',
					button=['OK', 'Cancel'],
					defaultButton='OK',
					cancelButton='Cancel',
					dismissString='Cancel')

		if result == 'OK':
			text_input = cmds.promptDialog( query=True, text=True )
			

			#create suffix list to hold camera names
			name_suffix = []

			#Iterate through the list and add the user input
			for index in name_suffix:
	   
				n = cmds.ls( text_input+index[0:] )
				
				try:
					child = cmds.listRelatives( n, children=True )
					if len(child) > 1:
						print "Camera has constrain %s"%child[1]
					else:
					 	cmds.parentConstraint('CAM:POS',n)
						print "Parent Constrain created"       
				 
				except NameError:
					cmds.confirmDialog( title='No Cameras', message='Reference Cameras first' )
			cmds.confirmDialog(title='parentConstraint', message='Check Cameras')
Beispiel #47
0
	def on_exportTrigger( self, *a ):
		BUTTONS = OK, CANCEL = 'Ok', 'Cancel'
		ret = cmd.promptDialog( t='Enter preset name', m='Enter a name for the preset file', b=BUTTONS, db=OK )
		if ret == OK:
			name = cmd.promptDialog( q=True, tx=True )
			if name:
				triggeredPresets.writeToPreset( name )
def checkin():
    print "checkin"
    saveFile()  # save the file before doing anything
    print "save"
    filePath = cmds.file(q=True, sceneName=True)
    print "filePath: " + filePath
    toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
    print "toCheckin: " + toCheckin
    toInstall = isRigAsset()
    specialInstallFiles = [os.path.join(os.environ["SHOTS_DIR"], "static/animation")]
    anim = isAnimationAsset()
    references = cmds.ls(references=True)
    loaded = []
    if amu.canCheckin(toCheckin) and saveGeo():  # objs must be saved before checkin
        comment = "Comment"
        commentPrompt = cmds.promptDialog(
            title="Comment",
            message="What changes did you make?",
            button=["OK", "Cancel"],
            defaultButton="OK",
            dismissString="Cancel",
            sf=True,
        )
        if commentPrompt == "OK":
            comment = cmds.promptDialog(query=True, text=True)
        else:
            return
        amu.setComment(toCheckin, comment)
        dest = amu.getCheckinDest(toCheckin)
        # if anim and showConfirmAlembicDialog() == 'Yes':
        #   for ref in references:
        #     if cmds.referenceQuery(ref, isLoaded=True):
        #       loaded.append(ref)
        #       cmds.file(unloadReference=ref)
        #   print loaded
        #   for ref in loaded:
        #     cmds.file(loadReference=ref)
        #     refPath = cmds.referenceQuery(ref, filename=True)
        #     assetName = getAssetName(refPath)
        #     print "\n\n\n\n**************************************************************\n"
        #     print dest
        #     print filePath
        #     print refPath
        #     print assetName
        #     saveFile()
        #     amu.runAlembicConverter(dest, filePath, filename=assetName)
        #     cmds.file(unloadReference=ref)

        #   for ref in loaded:
        #     cmds.file(loadReference=ref)

        saveFile()
        cmds.file(force=True, new=True)  # open new file
        dest = amu.checkin(toCheckin)  # checkin
        toInstall |= dest in specialInstallFiles
        srcFile = amu.getAvailableInstallFiles(dest)[0]
        if toInstall:
            amu.install(dest, srcFile)
    else:
        showFailDialog()
Beispiel #49
0
 def performTranferV1(self):
     getMesh=cmds.ls(sl=1)
     if len(getMesh)<2:
         print "select a skinned mesh group and an unskinned target mesh group"
         return
     else:
         pass
     getMeshController=getMesh[0]
     getMeshTarget=getMesh[1]
     getChildrenController=cmds.listRelatives(getMeshController, c=1, typ="transform")
     if getChildrenController==None:
         getChildrenController=([getMeshController])
     getChildrenTarget=cmds.listRelatives(getMeshTarget, c=1, typ="transform")
     if getChildrenTarget==None:
         getChildrenTarget=([getMeshTarget])
     result = cmds.promptDialog( 
                 title='find XML', 
                 message="Enter path", 
                 text="C:\Users\\"+str(getFolderName)+"\Documents\maya\projects\default\scenes\\", 
                 button=['Continue','Cancel'],
                 defaultButton='Continue', 
                 cancelButton='Cancel', 
                 dismissString='Cancel' )
     if result == 'Continue':
         skinPath=cmds.promptDialog(q=1)
         if skinPath:
             pass
         else:
             print "nothing collected"
     self.callJointsWin(getChildrenController, getChildrenTarget, skinPath)
 def simpleTemplateEditorAddCallbacks( *args):
  currTab = str(cmds.tabLayout(tabs1,q=1, st=1))
  currColChld = cmds.columnLayout(str(cmds.tabLayout(tabs1,q=1, st=1)),q=1, ca=1)
  curList = ""
  for temp in currColChld:
  	if cmds.textScrollList(temp, exists=True):
  		curList= temp
  tempSelAttrs = cmds.textScrollList(curList, q=1, si=True)
  tempSelIndAttrs = cmds.textScrollList(curList, q=1, sii=True)
  
  if cmds.textScrollList(curList, q=1, nsi=True)!=0:
  	result = cmds.promptDialog(title='Add Callback', message='Enter The Callback command for the selected attributes:',button=['OK', 'Cancel'],defaultButton='OK', cancelButton='Cancel', dismissString='Cancel')
  	if result == 'OK':
  		text = str(cmds.promptDialog(query=True, text=True))
  		if text != "":
  			for tempAttrI in tempSelIndAttrs:
  				cmds.textScrollList(curList, e=1, sii=tempAttrI)
  				tempAttrs = cmds.textScrollList(curList, q=1, si=True)
  				tempAttr =  tempAttrs[0]
  				tempAttrStrp = tempAttr.replace("      ","")
  				tempAttrStrp = tempAttrStrp.replace(" *","")
  				dictCallbacks[currTab + "_" + tempAttrStrp] = text
				if (cmds.menuItem(verbMenuI, q=1, checkBox = True)) == True:
		  			print ('  - Callback created for ' + tempAttrStrp + ' in view "' + currTab + '"')
  				cmds.textScrollList(curList, e=1, rii=tempAttrI)
				cmds.textScrollList(curList, e=1, ap=[tempAttrI,"      " + tempAttrStrp+ " *"])
Beispiel #51
0
	def addSetCB(self, args) :
		result = cmds.promptDialog(title='Add Color Set', message='Enter Set Name:', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel')
		if result == 'OK' :
			sname = cmds.promptDialog(q=True, text=True)
			cmds.select(self.objectSet)
			cmds.polyColorSet(cr=True, cs=sname)
			self.refreshColorSets()
Beispiel #52
0
def shaderAssigner() :
	# Assigning temporary shader to selected objects
	sels = mc.ls( sl=True )
	name = ''
	side = ''

	nameResult = mc.promptDialog(
					title='Shading Name',
					message='Enter Name:',
					button=['OK', 'Cancel'],
					defaultButton='OK',
					cancelButton='Cancel',
					dismissString='Cancel'
				)
	
	if nameResult == 'OK':
	    name = mc.promptDialog(query=True, text=True)
    
	if name :
		
		shadingName = '%sTmp_lambert' % name
		
		if not mc.objExists( shadingName ) :
			
			mc.shadingNode( 'lambert' , asShader=True , n=shadingName )
		
		mc.select( sels , r=True )
		cmd = 'hyperShade -assign %s;' % shadingName
		mm.eval( cmd )
		
		mc.select( shadingName , r=True )
	def __init__(self) :

		# create a promptDialog for the base group name of our mesh this will help to
		# avoid name conflicts, may be good to modify this at some stage to check if mesh
		# exists and prompt to replace data / key
		result = cmds.promptDialog(
															title='Name',
															message='Enter Name for import',
															button=['OK', 'Cancel'],
															defaultButton='OK',
															cancelButton='Cancel',
															dismissString='Cancel')

		# if ok was pressed lets process the data
		if result == 'OK':
			# first we get the text entered by the user
			self.m_text = cmds.promptDialog(query=True, text=True)
			# now get the obj file to import
			self.m_objFileName=cmds.fileDialog2(caption="Please select obj file to import",fileFilter="*.obj", fm=1)

			cmds.file(self.m_objFileName,i=True,type="OBJ",ns=self.m_text)
			# now the xml file
			basicFilter = "*.xml"
			self.m_pointBakeFile=cmds.fileDialog2(caption="Please select xml file to import",fileFilter=basicFilter, fm=1)
			# select the object imported
			print self.m_pointBakeFile
			cmds.select("%s:Mesh"%(self.m_text))
			# and pass control back to the parser
			parser = xml.sax.make_parser()
			parser.setContentHandler(ParseHandler("%s:Mesh"%(self.m_text)))
			parser.parse(open(str(self.m_pointBakeFile[0]),"r"))
    def new_scene(self):

        cmds.file(newFile=True, force=True)
        location = "{0}{1}{2}".format(os.path.dirname(os.path.realpath(__file__)), os.path.sep, self.cleanScene)
        self.set_project(location)
        cmds.file("cleanScene.ma", open=True)

        select_dir = pm.fileDialog2(fileMode=2, dialogStyle=3, startingDirectory=self.statusDir)

        if select_dir != None:
            print select_dir[0]
            sDir = str(select_dir[0])

            result = cmds.promptDialog(
                title='Asset Name',
                message='Enter Name:',
                button=['OK', 'Cancel'],
                defaultButton='OK',
                cancelButton='Cancel',
                dismissString='Cancel')

            if result == 'OK':
                assetName = cmds.promptDialog(query=True, text=True)
            print assetName

            # makes project folder
            projectFolder = os.path.join(sDir, assetName)
            if not os.path.exists(projectFolder):
                print "Creating {0}".format(projectFolder)
                os.makedirs(projectFolder)

            # makes scenes folder
            scenesFolder = os.path.join(projectFolder, SCENE_FOLDER)
            if not os.path.exists(scenesFolder):
                print "Creating {0}".format(scenesFolder)
                os.makedirs(scenesFolder)

                # makes turntable folder
            turntableFolder = os.path.join(projectFolder, TURNTABLE_FOLDER)
            if not os.path.exists(turntableFolder):
                print "Creating {0}".format(turntableFolder)
                os.makedirs(turntableFolder)

                # makes export folder
            exportFolder = os.path.join(projectFolder, EXPORT_FOLDER)
            if not os.path.exists(exportFolder):
                print "Creating {0}".format(exportFolder)
                os.makedirs(exportFolder)

            # makes sourceimages folder
            sourceimagesFolder = os.path.join(projectFolder, SOURCEIMAGES_FOLDER)
            if not os.path.exists(sourceimagesFolder):
                print "Creating {0}".format(sourceimagesFolder)
                os.makedirs(sourceimagesFolder)

            fileName = assetName + "_v001_" + get_author_initials() + ".ma"
            fileSavePath = os.path.join(scenesFolder, fileName)
            print fileSavePath
            cmds.file(rename=fileSavePath)
            cmds.file(save=True)