Exemplo n.º 1
0
def getExportFilePathUI():
    mode = cmds.radioButtonGrp('em_modeRadio', q=1, select=1)
    if mode == 1:
        filePath = cmds.fileDialog(mode=1, dm=('*.obj'))
    if mode == 2:
        filePath = cmds.fileDialog(mode=1, dm=('*.mdd'))
    if mode == 3:
        filePath = cmds.fileDialog(mode=1, dm=('*.geo'))
    filePath = pathToWindows(filePath)
    cmds.textFieldButtonGrp('em_fileName', e=1, text=filePath)
    return filePath
Exemplo n.º 2
0
def getExportFilePathUI():
	mode  = cmds.radioButtonGrp( 'em_modeRadio',q=1, select=1)
	if mode ==1:
		filePath = cmds.fileDialog(mode=1, dm=('*.obj') )
	if mode ==2:
		filePath = cmds.fileDialog(mode=1, dm=('*.mdd') )
	if mode ==3:
		filePath = cmds.fileDialog(mode=1, dm=('*.geo') )		
	filePath = pathToWindows(filePath)
	cmds.textFieldButtonGrp('em_fileName',e=1, text=filePath)
	return filePath
Exemplo n.º 3
0
def saveToLocal(showWarning=True):
	
	episod, shot = getEpiAndShotFromUI()
	if not shot:	return
	
	if showWarning:
		warnMsg = 'SceneName from window doesnt match with opened scene\'s name.\nSceneName will be taken from window by default.\nDo you want to continue?'
		if not filenamesMatch(episod, shot):
			rslt = mc.confirmDialog(t='Warning', m=warnMsg, b=['Continue', 'Cancel'], db='Continue', cb='Cancel', ds='Cancel')
			if rslt == 'Cancel':
				return
	
	expr = '^%s_%s%ssh%s_%s_.*[.]ma' % (util.projShort, util.epOrSeq, episod, shot, util.deptDic['short'])
	dfltName = '%sv00.ma' % expr[1:-7]
	pathToSave = mc.fileDialog(m=1, dm='*.ma', dfn=dfltName)
	
	if pathToSave:
		filename = pathToSave.split('/')[-1]
		if re.search(expr, filename):	# Check if filename matches the required format
			util.correctFrames(episod, shot)
			
			#joj - March 9
			Utils.switchToProxy()
			
			mc.file(rn=pathToSave)
			mc.file(s=True, typ='mayaAscii')
			mc.confirmDialog(t='Success', m='Saved as:\n%s' % pathToSave, b='THANX')
		else:
			mc.confirmDialog(t='Error', m='SceneName format is incorrect', b='SORRY')
			saveToLocal(False)
Exemplo n.º 4
0
def import_pose(*arg):
    Data_name = maya.tabLayout(tabID, q=True, st=True)
    temp_data = Data_dic[Data_name]
    # pose=dict()
    print temp_data.keylist
    xml_file_path = maya.fileDialog(dm='*.xml')
    print xml_file_path
    dom = parse(xml_file_path)
    for node in dom.getElementsByTagName('Posename'):
        controller = dict()
        namekey = node.attributes.keys()
        print namekey[0]
        posepair = node.attributes[namekey[0]]
        print posepair.value
        for node in dom.getElementsByTagName('Controller'):
            attrlist = []
            controllerkey = node.attributes.keys()
            print controllerkey[0]
            controllerpair = node.attributes[controllerkey[0]]
            for nnode in node.getElementsByTagName('Attributes'):
                attrs = nnode.attributes.keys()
                # print attrs[0]
                pair = nnode.attributes[attrs[0]]
                #print (str(pair.name)+'='+str(pair.value))
                print pair.value
                attrlist.append(str(pair.value))
            print controllerpair.value
            print attrlist
            controller[controllerpair.value] = attrlist
        temp_data.pose_dict[posepair.value] = controller
        maya.textScrollList(Data_name + '_poselist', e=True, a=posepair.value)
    print temp_data.pose_dict
    updateXML_data()
Exemplo n.º 5
0
 def SK_importCurveShape(self):
     filePath = rig.fileDialog(dm='*.cs', m=0)
     if filePath:
         readFile = open(filePath, 'r')
         ShapeData = pickle.load(readFile)
         readFile.close()
         self.SK_setCurveShape(ShapeData)
Exemplo n.º 6
0
    def _loadTab(self):
    	    
    	    print("Load Tab")
    	    
    	    path = cmds.fileDialog( mode=0)
    	    # load
    	    if( path ):
    	    	    # Reading fileInfo
		    fileInfo = open( path, "r" )
		    tabName = pickle.load( fileInfo )
		    frameNames = pickle.load( fileInfo )
		    frames = pickle.load( fileInfo )
		    fileInfo.close()
		        
		    # Create Tab with tabname
		    tab = self._addTab( tabName )
		    for frame in frameNames:
		    	# frame[0]  the name of the frame
		    	# frame[1] is the layoutName (this is done so the dictionary doesn't get overlap)
		   	# frameGrp = self._addFrame( frame[0] )
		   	
		   	newAttr = FrameGroup( tab , frame[0] )
		   	self.tabs[self.tabNames[-1]].append( newAttr )
		   	
			for attrItem in frames[frame[1]]:
		   		if( cmds.objExists(attrItem) ):
		   			newAttr.addAttr( attrItem )
		    '''
		    print(tabName)
		    print(frameNames)
		    print(frames)
		    '''
    	    else:
    	    	    print("Load Cancelled.")
Exemplo n.º 7
0
    def savePreset(self):

        dir = utils.INIHandler.load_info(self.__EAAtlasFile, "dir")
        if dir: dir += "/"

        file = cmds.fileDialog(m=1, dm=dir + '*.atl')  # @UndefinedVariable

        if file:

            jsonOUT = json.loads('{}')

            jsonOUT["atlasSize"] = self.atlasSize
            jsonOUT["fileOutput"] = self.fileOutput
            jsonOUT["outputWidth"] = int(self.outputWidth)
            jsonOUT["outputHeight"] = int(self.outputHeight)
            jsonOUT["meshList"] = {}

            for k in self.listOfAtlasMeshes:

                assert isinstance(k, AtlasMesh)
                item = {
                    "texture": k.texture,
                    "color": k.color,
                    "id": k.id,
                    "coords": k.coords
                }
                jsonOUT["meshList"][k.meshName] = item

            with open(file, 'wb') as fp:
                json.dump(jsonOUT, fp)

            utils.INIHandler.save_info(self.__EAAtlasFile, "dir",
                                       os.path.dirname(file))
Exemplo n.º 8
0
    def loadShapes(cls):
        path = cmds.fileDialog(mode=0, directoryMask="*.shapes")
        success = "Successfuly loaded shape {0} for {1}."
        err = "{0} does not exist, skipping."
        the_file = open(path, 'rb')
        shapesData = pickle.load(the_file)
        print shapesData

        for obj in shapesData.keys():

            if not cmds.objExists(obj):
                print err.format(obj)
                continue

            # parent does exist
            # delete shapes from obj

            cmds.delete(cmds.listRelatives(obj, s=True, type="nurbsCurve"))

            # initialize object as curve
            con = cls(name='L_' + obj)
            con.name = obj

            for shape in shapesData[obj].keys():
                pos = shapesData[obj][shape]['positions']
                dg = shapesData[obj][shape]['degree']
                knots = shapesData[obj][shape]['knots']
                color = shapesData[obj][shape]['color']
                period = shapesData[obj][shape]['period']

                p = True if period > 0 else False
                con.color = color
                curve = cmds.curve(degree=dg, point=pos, knot=knots, per=p)
                con.get_shape_from(curve, destroy=True, replace=False)
                print success.format(shape, obj)
Exemplo n.º 9
0
 def convertPrep(fileFormat):
     filePath = cmds.fileDialog(
         title="Convert DPX To {}".format(str.upper(fileFormat)))
     filename, file_extension = os.path.splitext(filePath)
     file_list = glob.glob(filename[:-4] + "*" +
                           file_extension)  # create filtered list of files
     frames = [f[-8:-4] for f in file_list]
     print min(frames), max(frames)
     withHash = (filename[:-4] + "####" + file_extension)
     folderPath, fullFilename = os.path.split(withHash)
     linearPath = folderPath + "/" + fileFormat + "/"
     exportPath = linearPath + fullFilename
     exportFilename = (exportPath[:-4] + "." + str.lower(fileFormat))
     print exportFilename
     if not os.path.isdir(linearPath):
         os.mkdir(linearPath)
         print "Created dir " + linearPath
     else:
         print "Path exists :" + linearPath
     #The command for a shell:
     sillyString = "sh /mnt/pipeline/ATK_PIPELINE/nuke/launcher/workstation/linux/Nuke_Batch_Launcher.sh -x /mnt/resources/nuke/lightingBackplates/lightingBackplates{}_v001.nk '{}' '{}' -F {}-{}".format(
         fileFormat, withHash, exportFilename, str(min(frames)),
         str(max(frames)))
     print sillyString
     return sillyString
Exemplo n.º 10
0
    def loadPreset(self):

        dir = utils.INIHandler.load_info(self.__EAAtlasFile, "dir")
        if dir: dir += "/"

        file = cmds.fileDialog(m=0, dm=dir + '*.atl')  # @UndefinedVariable

        if os.path.exists(file):

            self.listOfAtlasMeshes = []

            jsonIN = None

            with open(file, 'rb') as fp:
                jsonIN = json.load(fp)

            self.atlasSize = jsonIN["atlasSize"]
            self.fileOutput = jsonIN["fileOutput"]
            self.outputWidth = jsonIN["outputWidth"]
            self.outputHeight = jsonIN["outputHeight"]
            for k in jsonIN["meshList"]:

                meshName = k
                texture = jsonIN["meshList"][k]["texture"]
                id = int(jsonIN["meshList"][k]["id"])
                color = jsonIN["meshList"][k]["color"]
                coords = jsonIN["meshList"][k]["coords"]

                mesh = AtlasMesh(meshName, texture, id, color, coords)
                self.listOfAtlasMeshes.append(mesh)

                utils.INIHandler.save_info(self.__EAAtlasFile, "dir",
                                           os.path.dirname(file))
Exemplo n.º 11
0
def writeSelAttrFile():
	'''
	Writes the selected attributes from the textScrollList to a file.
	'''
	# Let the user choose where the files is being saved to.
	# Starting point will be the maya folder.
	mayaFolder = cmds.internalVar( userAppDir=True )
	# File Dialog
	# sba will be the file extension.
	filePath = cmds.fileDialog( mode=1, directoryMask= mayaFolder+"*.sba")
	
	print( "Choosen file: " + filePath )
	
	# Gather the attributes from the textScrollList
	selectedTSL = cmds.textScrollList( "sbaKeyTSL", q=True, si=True)
	
	# Open File
	attrFile = open( filePath, "w" )  # Will overwrite the file if it allready exists!
	
	# Loop through one element at a time writing it to a file.
	for item in selectedTSL:
		attrFile.write( item + "\n" )
	
	# Close File		
	attrFile.close()
Exemplo n.º 12
0
    def _saveTab(self):
        '''
	The name of the tab 
	The frames included
	the attributes for each frame
	'''

        # Prompt where to save the file.

        # pack data

        currTab = cmds.tabLayout(self.mainTab, q=True, selectTab=True)
        tabIndex = cmds.tabLayout(
            self.mainTab, q=True,
            selectTabIndex=True) - 1  # tab index are 1 based.
        tabLabels = cmds.tabLayout(self.mainTab, q=True, tl=True)

        tabName = tabLabels[tabIndex]
        frameNames = []
        frames = {}

        for frameInfo in self.tabs[self.tabNames[tabIndex]]:
            frameNames.append([frameInfo.frameName, frameInfo.mainLayout])
            frames[frameInfo.mainLayout] = frameInfo.attrs

        path = cmds.fileDialog(mode=1)
        if (path):
            fileInfo = open(path, "w")
            pickle.dump(tabName, fileInfo)
            pickle.dump(frameNames, fileInfo)
            pickle.dump(frames, fileInfo)
            fileInfo.close()
        else:
            print("Save Cancelled.")
Exemplo n.º 13
0
def writeSelAttrFile():
    """
	Writes the selected attributes from the textScrollList to a file.
	"""
    # Let the user choose where the files is being saved to.
    # Starting point will be the maya folder.
    mayaFolder = cmds.internalVar(userAppDir=True)
    # File Dialog
    # sba will be the file extension.
    filePath = cmds.fileDialog(mode=1, directoryMask=mayaFolder + "*.sba")

    print("Choosen file: " + filePath)

    # Gather the attributes from the textScrollList
    selectedTSL = cmds.textScrollList("sbaKeyTSL", q=True, si=True)

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

    # Loop through one element at a time writing it to a file.
    for item in selectedTSL:
        attrFile.write(item + "\n")

        # Close File
    attrFile.close()
Exemplo n.º 14
0
def importABCasVRMesh():		
	pathPick = cmds.fileDialog()
	path = os.path.split(pathPick)[1]
	name = path.split(".")[0]

	# Export alembic as VRMesh   
	mel.eval('vrayCreateProxyExisting("%s", "geo/%s")' % (name, path))
Exemplo n.º 15
0
def readAttr():
    """
	Read attributes from a chosen file.
	"""

    # Get information from file
    # Starting at the maya folder and limiting to extension .sba
    mayaFolder = cmds.internalVar(userAppDir=True)
    # File Dialog
    # sba will be the file extension.
    filePath = cmds.fileDialog(mode=0, directoryMask=mayaFolder + "*.sba")

    print("Choosen file: " + filePath)

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

    attrs = attrFile.readlines()

    # Close File
    attrFile.close()

    # loop through file content adding to the textScrollList
    for attr in attrs:
        # Check to see if the attribute allready exists in the textScrollList
        attr = attr.rstrip()
        # all the current tsl items
        allItemsTSL = cmds.textScrollList("sbaKeyTSL", q=True, allItems=True)
        if allItemsTSL and (attr in allItemsTSL):
            print(attr + " all ready exists in the list.")
        else:
            cmds.textScrollList("sbaKeyTSL", edit=True, append=attr)
def LoadRigAttribute(*args):

    # Open Dialog to select csv file
    dialog = cmds.fileDialog(m=0);        
    o_file = str(dialog)
    #print o_file

    # Load csv file
    reader = csv.reader(file(o_file, 'r'))
    #print reader

    # skip first row line
    header = next(reader)

    # Show each attribute
    for row in reader:
        #print row[0] + ',' + row[1] + ',' + row[2]
        number = int(row[0])
        ctrlName = row[1];
        numAttrib = int(row[2])

        for i in range(numAttrib):
            att = row[3 + i*2+0]
            val = float(row[3 + i*2+1])
            #print ctrlName + "." + att + " : " + str(val)

            settable = cmds.getAttr(ctrlName + "." + att, settable = True)
            lockable = cmds.getAttr(ctrlName + "." + att, lock = True)

            if(settable == True and lockable == False):
                gettype = cmds.setAttr(ctrlName + "." + att, val)
Exemplo n.º 17
0
    def loadShapes(cls):
        path = cmds.fileDialog(mode=0, directoryMask="*.shapes")
        success = "Successfuly loaded shape {0} for {1}."
        err = "{0} does not exist, skipping."
        the_file = open(path, 'rb')
        shapesData = pickle.load(the_file)
        print shapesData

        for obj in shapesData.keys():

            if not cmds.objExists(obj):
                print err.format(obj)
                continue

            # parent does exist
            # delete shapes from obj

            cmds.delete(cmds.listRelatives(obj, s=True, type="nurbsCurve"))

            # initialize object as curve
            con = cls(name='L_' + obj)
            con.name = obj

            for shape in shapesData[obj].keys():
                pos = shapesData[obj][shape]['positions']
                dg = shapesData[obj][shape]['degree']
                knots = shapesData[obj][shape]['knots']
                color = shapesData[obj][shape]['color']
                period = shapesData[obj][shape]['period']

                p = True if period > 0 else False
                con.color = color
                curve = cmds.curve(degree=dg, point=pos, knot=knots, per=p)
                con.get_shape_from(curve, destroy=True, replace=False)
                print success.format(shape, obj)
Exemplo n.º 18
0
    def _saveTab(self):
	'''
	The name of the tab 
	The frames included
	the attributes for each frame
	'''
	
	# Prompt where to save the file.

	# pack data
	

    	currTab = cmds.tabLayout( self.mainTab, q=True, selectTab=True)
    	tabIndex = cmds.tabLayout( self.mainTab, q=True, selectTabIndex=True) - 1 # tab index are 1 based.
	tabLabels = cmds.tabLayout( self.mainTab, q=True, tl=True )
	
	tabName = tabLabels[tabIndex]
	frameNames = []	
	frames = {}

	
	for frameInfo in self.tabs[self.tabNames[tabIndex]]:
		frameNames.append([frameInfo.frameName, frameInfo.mainLayout])
		frames[frameInfo.mainLayout] = frameInfo.attrs
	
	path = cmds.fileDialog(mode=1)
	if(path):
		fileInfo = open( path, "w" )
		pickle.dump( tabName, fileInfo  )
		pickle.dump( frameNames, fileInfo )
		pickle.dump( frames, fileInfo )
		fileInfo.close()
	else:
		print("Save Cancelled.")
Exemplo n.º 19
0
    def load_shapes(cls):
        path = cmds.fileDialog(mode=0, directoryMask="*.shapes")
        success = "Successfuly loaded shape {0} for {1}."
        err = "{0} does not exist, skipping."

        with open(path, 'rb') as ctrl_file:
            shapes_data = pickle.load(ctrl_file)

        for obj in shapes_data:
            if not cmds.objExists(obj):
                log.error(err.format(obj))
                continue

            # parent does exist
            # delete shapes from obj
            cmds.delete(cmds.listRelatives(obj, s=True, type="nurbsCurve"))

            # initialize object as curve
            con = cls.compose(descriptor=obj, side=cls.CONFIG.LEFT)

            for shape in shapes_data[obj]:
                shape = shapes_data[obj][shape]
                pos = shape['positions']
                dg = shape['degree']
                knots = shape['knots']
                color = shape['color']
                period = shape['period']

                p = True if period > 0 else False
                con.color = color
                curve = cmds.curve(degree=dg, point=pos, knot=knots, per=p)
                con.get_shape_from(curve, destroy=True, replace=False)
                log.info(success.format(shape, obj))
Exemplo n.º 20
0
 def saveBtnCmd(self, *args):
     """Called when the Save Light Setup button is pressed, saves data to file"""
     print("Save Menu Btn has been clicked")
     cmds.select("Three_Point_Lights")
     rootNodes = self.getSelection()
     if rootNodes is None:
         try:
             rootNodes = self.getSelection()
         except:
             return
      #defaults to home directory for the moment
     filePath = ''
     # Maya 2011 and newer use fileDialog2
     try:
         filePath = cmds.fileDialog2(
             ff=self.fileFilter, fileMode=0
         )
     # BUG: Maya 2008 and older may, on some versions of OS X, return the
     # path with no separator between the directory and file names:
     # e.g., /users/adam/Desktopuntitled.pse
     except:
         filePath = cmds.fileDialog(
             dm='*.%s' % kLightFileExtension, mode=1
         )
         # early out of the dialog was canceled
     if filePath is None or len(filePath) < 1: return
     if isinstance(filePath, list): filePath = filePath[0]
     exportSetup(filePath, cmds.ls(sl=True, type='transform'))
Exemplo n.º 21
0
def readAttr():
	'''
	Read attributes from a chosen file.
	'''
	
	# Get information from file
	# Starting at the maya folder and limiting to extension .sba
	mayaFolder = cmds.internalVar( userAppDir=True )
	# File Dialog
	# sba will be the file extension.
	filePath = cmds.fileDialog( mode=0, directoryMask= mayaFolder+"*.sba")
		
	print( "Choosen file: " + filePath )
	
	# Open File
	attrFile = open( filePath, "r" )  # Will overwrite the file if it allready exists!

	attrs = attrFile.readlines()
	
	# Close File		
	attrFile.close()

	# loop through file content adding to the textScrollList
	for attr in attrs:
		# Check to see if the attribute allready exists in the textScrollList
		attr = attr.rstrip()
		# all the current tsl items
		allItemsTSL = cmds.textScrollList("sbaKeyTSL", q=True, allItems=True)
		if( allItemsTSL and ( attr in allItemsTSL) ):
			print( attr + " all ready exists in the list.")
		else:
			cmds.textScrollList("sbaKeyTSL", edit=True, append=attr)			
Exemplo n.º 22
0
 def importCurveShape(self):
         filePath=mc.fileDialog(dm='*.cs',m=0)
         if filePath:
                 readFile = open(filePath,'r')
                 ShapeData = pickle.load(readFile)
                 readFile.close()
                 self.setCurveShape(ShapeData)
Exemplo n.º 23
0
    def selectFile(self, forSave):
        '''
        shows UI for file selection; returns file name or None 
        '''
        extensionList = ";".join(
            map(lambda a: "*.%s" % a, self.ioFormat.recommendedExtensions))
        caption = ('Export as %s'
                   if forSave else 'Import from %s') % self.ioFormat.title
        fileFilter = 'Layer data in %s format (%s);;All Files (*.*)' % (
            self.ioFormat.title, extensionList)

        if Utils.getMayaVersion() >= Utils.MAYA2011:
            result = cmds.fileDialog2(dialogStyle=1,
                                      caption=caption,
                                      fileFilter=fileFilter,
                                      fileMode=0 if forSave else 1,
                                      returnFilter=True)
            if result is None:
                return None
            return result[0]
        else:
            result = cmds.fileDialog(title=caption,
                                     directoryMask=extensionList,
                                     mode=1 if forSave else 0)
            if result == "":
                return None

            return result
Exemplo n.º 24
0
    def _loadTab(self):

        print("Load Tab")

        path = cmds.fileDialog(mode=0)
        # load
        if (path):
            # Reading fileInfo
            fileInfo = open(path, "r")
            tabName = pickle.load(fileInfo)
            frameNames = pickle.load(fileInfo)
            frames = pickle.load(fileInfo)
            fileInfo.close()

            # Create Tab with tabname
            tab = self._addTab(tabName)
            for frame in frameNames:
                # frame[0]  the name of the frame
                # frame[1] is the layoutName (this is done so the dictionary doesn't get overlap)
                # frameGrp = self._addFrame( frame[0] )

                newAttr = FrameGroup(tab, frame[0])
                self.tabs[self.tabNames[-1]].append(newAttr)

                for attrItem in frames[frame[1]]:
                    if (cmds.objExists(attrItem)):
                        newAttr.addAttr(attrItem)
            '''
		    print(tabName)
		    print(frameNames)
		    print(frames)
		    '''
        else:
            print("Load Cancelled.")
Exemplo n.º 25
0
 def loadImageDir(self,*args):
     """ 
     opens dialog so user can browse to the overscan image.
     This will not be neccessary once standard paths for the Tools shelf 
     and icons/images are in place.
     """
     dir = cmds.fileDialog( directoryMask='*.png' )
     cmds.textFieldButtonGrp(self.imageField,edit=True,text=dir)
def openSceneButtonFunction(*args):
    import os
    global sceneFileName
    global selectedFileName
    selectedFileName = cmds.fileDialog()
    cmds.launchImageEditor(vif=selectedFileName)
    sceneFileName = os.path.basename(selectedFileName)
    cmds.textField('sceneName', w=400, e=1, fi=sceneFileName)
Exemplo n.º 27
0
 def loadSlateDir(self, *args):
     """ 
     opens dialog so user can browse to the overscan image.
     This will not be neccessary once standard paths for the Tools shelf 
     and icons/images are in place.
     """
     dir = cmds.fileDialog(directoryMask='*.png')
     cmds.textFieldButtonGrp(self.slateField, edit=True, text=dir)
	def fileSaveDialog(self, *args):
		
		#!!! look into this
		
		saveFileName = self.base.strip()
		
		#self.downloadPath = tkFileDialog.asksaveasfile(mode='w', initialfile=str(saveFileName))
		self.downloadPath = cmds.fileDialog(mode=1, defaultFileName=str(saveFileName))
def openSceneButtonFunction(*args):
	import os
	global sceneFileName
	global selectedFileName
	selectedFileName=cmds.fileDialog()
	cmds.launchImageEditor(vif=selectedFileName)
	sceneFileName=os.path.basename(selectedFileName)
	cmds.textField('sceneName', w=400, e=1, fi=sceneFileName)
def read_PFtrack_3dPoint():
    basicFilter = '*.txt'
    filename =cmds.fileDialog(dm=basicFilter,title='Open_pftrack_3dPoints_file')#'D:/suvey_points_0110.txt'
    
    if not (filename==''):
        result=read_pf3dpoints_asciifile(filename)
        if len(result)>0:
            spread_PF3dPoints(result)
def saveFileDialog(*args):
    dialog = cmds.fileDialog(m=1);
    
#    fdialog = pm.fileDialog2(
#       ocm="on_save_dialog_file",
#       fm=0,
#        ff="CSV Files (*.csv);;All Files (*.*)",
#        dialogStyle=2)
    
    o_file = str(dialog)
    #print o_file

    if not (cmds.file(o_file,query=True, exists=True)):
        tmp_csv_file = open(o_file, 'w' ,os.O_CREAT)
    else:
        tmp_csv_file = open(o_file, 'w')
    
    writer = csv.writer(tmp_csv_file, lineterminator='\n')
    
    all_rows = cmds.scriptTable('table', query=True, rows=True)
    for o_r in range(all_rows):
            
        all_colums = cmds.scriptTable('table', query=True, columns=True)
        data_list = []
        for o_c in range( all_colums - 1):
            if o_r == 0:
                data_list = ["No.", "JointName", "transrateX","transrateY","transrateZ"]
            else:
                cell_list = cmds.scriptTable('table', cellIndex=(o_r,o_c + 1), query=True, cellValue=True)
                if o_c == 0:
                    if type(cell_list) == list:
                        cell_text = "".join(cell_list)
                        #print cell_text
                    elif cell_list == None:
                        cell_text = u''
                    else:
                        cell_text = cell_list
                    data_list.append(cell_text)
                elif o_c == 1:
                    if type(cell_list) == list:
                        cell_text = "".join(cell_list)
                        #print cell_text
                    elif cell_list == None:
                        cell_text = u''
                    else:
                        cell_text = cell_list
                    data_list.append(cell_text)
                else:
                    if type(cell_list) == list:
                        cell_text = "".join(cell_list)
                    elif cell_list == None:
                        cell_text = u''
                    else:
                        cell_text = cell_list
                    data_list.append(cell_text)
        writer.writerow(data_list)
    tmp_csv_file.close()
Exemplo n.º 32
0
 def fileDialog(self, label="", callback=None):
     """ Draw a File input dialog
     @type  label: string
     @param label: the windows title       
     @type  callback: function
     @param callback: the callback function to call
     """
     filename = cmds.fileDialog(t=label)
     callback(str(filename))
Exemplo n.º 33
0
 def exportCurveShape(self):
         filePath=mc.fileDialog(dm='*.cs',m=1)
         if filePath:
                 if 'cs' != filePath.split('.')[-1]:
                         filePath += '.cs'
                 ShapeData = self.getCurveShape()
                 newFile = open(filePath,'w')
                 pickle.dump(ShapeData,newFile)
                 newFile.close()
    def fileSaveDialog(self, *args):

        #!!! look into this

        saveFileName = self.base.strip()

        #self.downloadPath = tkFileDialog.asksaveasfile(mode='w', initialfile=str(saveFileName))
        self.downloadPath = cmds.fileDialog(mode=1,
                                            defaultFileName=str(saveFileName))
Exemplo n.º 35
0
 def SK_exportCurveShape(self):
     filePath = rig.fileDialog(dm='*.cs', m=1)
     if filePath:
         if 'cs' != filePath.split('.')[-1]:
             filePath += '.cs'
         ShapeData = self.SK_getCurveShape()
         newFile = open(filePath, 'w')
         pickle.dump(ShapeData, newFile)
         newFile.close()
Exemplo n.º 36
0
Arquivo: mayaUI.py Projeto: gj210/upy
 def fileDialog(self,label="",callback=None):
     """ Draw a File input dialog
     @type  label: string
     @param label: the windows title       
     @type  callback: function
     @param callback: the callback function to call
     """         
     filename = cmds.fileDialog(t=label)
     callback(str(filename))
Exemplo n.º 37
0
    def pickPhotoshopPath(self):

        photoshopLineEdit = qt_utils.getControl(
            qt_utils.RawWidget("EAprefPhotoshopPath", QLineEdit))
        folder = os.path.dirname(photoshopLineEdit.text())

        photoshopPath = cmds.fileDialog(m=0, dm='%s/*.exe' %
                                        folder)  # @UndefinedVariable
        if os.path.exists(photoshopPath):
            photoshopLineEdit.setText(photoshopPath)
Exemplo n.º 38
0
def promptExport(pos, start, end, cols, tags):
    '''
	File prompt is given
	'''
    results = cmds.fileDialog(m=0, dm='*.xls')
    if (results):
        temp = baseballExport(results, pos, start, end, cols, tags)
        return temp
    else:
        print("Cancelled.")
Exemplo n.º 39
0
def promptExport( pos, start, end, cols, tags ):
	'''
	File prompt is given
	'''
	results = cmds.fileDialog(  m=0, dm='*.xls' )
	if( results ):
		temp = baseballExport( results, pos, start, end, cols, tags )
		return temp
	else:
		print("Cancelled.")
Exemplo n.º 40
0
def cc_import(*arg):
	filepath=maya.fileDialog(m=0,t='Import')
	print filepath
	filenumbers=maya.intField(filenumberGUI,q=True,v=True)
	print filenumbers
	nameSpace=maya.textField(nameSpaceGUI,q=True,tx=True)
	print nameSpace
	if(filepath!=None):
		for i in range(filenumbers):
			maya.file(filepath,i=True,ns=nameSpace)
Exemplo n.º 41
0
    def loadCmd(self, *args):

        filePath = ''
        try:
            filePath = cmds.fileDialog2(ff=self.fileFilter, fileMode=1)
        except:
            filePath = cmds.fileDialog(dm='*.%s' % kPoseFileExtension, mode=0)

        if filePath is None or len(filePath) < 1: return
        if isinstance(filePath, list): filePath = filePath[0]
        importFile(filePath)
Exemplo n.º 42
0
def import_anim():
    # メッセージ
    # cmds.inViewMessage( amg='<hl>「モーションをベイク」</hl>を押してください。', pos='midCenter', fade=True, fit=1,fst=4000,fts=20 )

    cmds.select("Root_M")
    cmds.select("foot_R_controller", add=True)
    cmds.select("foot_L_controller", add=True)
    cmds.select("Knee_R_Locator", add=True)
    cmds.select("Knee_L_Locator", add=True)

    fileName = cmds.fileDialog(dm="*.anim")
    cmds.file(fileName, ra=True, pr=True, typ="animImport", i=True)
Exemplo n.º 43
0
def import_anim():
    #メッセージ
    #cmds.inViewMessage( amg='<hl>「モーションをベイク」</hl>を押してください。', pos='midCenter', fade=True, fit=1,fst=4000,fts=20 )

    cmds.select('Root_M')
    cmds.select('foot_R_controller', add=True)
    cmds.select('foot_L_controller', add=True)
    cmds.select('Knee_R_Locator', add=True)
    cmds.select('Knee_L_Locator', add=True)

    fileName = cmds.fileDialog(dm='*.anim')
    cmds.file(fileName, ra=True, pr=True, typ='animImport', i=True)
Exemplo n.º 44
0
def shelfFromFile():
    """
	Creates a shelf button to keyframe the attributes straight from a previously saved file.
	"""
    # Get information from file
    # Starting at the maya folder and limiting to extension .sba
    mayaFolder = cmds.internalVar(userAppDir=True)
    # File Dialog
    # sba will be the file extension.
    filePath = cmds.fileDialog(mode=0, directoryMask=mayaFolder + "*.sba")

    print("Choosen file: " + filePath)

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

    attrs = attrFile.readlines()

    # Close File
    attrFile.close()

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

    print(attrToShelf)

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

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

    # if( results ):

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

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

    print(keyFrameLines)
    # Create the shelfButton
    cmds.shelfButton(l=fileName, iol=fileName, c=keyFrameLines, image="setKey.xpm", parent=currentShelf)
Exemplo n.º 45
0
def writeXML(data):

	# prepare path, it will print out in the same path of the script.)
	#curPath = os.path.split( __file__ )[0]
	#xmlFile = os.path.join( curPath, fileName )
	
	results = cmds.fileDialog( m=1, dm="*.xls" )
	if(results):
		fileInfo = open( results, "w" )
		
		fileInfo.write(data)
		fileInfo.close()
	else:
		print("Cancelled.")
Exemplo n.º 46
0
	def imageCard(self):
		selImage=mc.fileDialog()
		material=mc.shadingNode('lambert',asShader=1)
		fileNode=mc.shadingNode('file',asTexture=1)
		mc.setAttr(fileNode+'.fileTextureName',selImage,typ='string')
		mc.connectAttr(fileNode+'.outColor', material+'.color')
		sizeFactor=0.01
		imageSize=mc.getAttr(fileNode+'.outSize')
		modelPlane=mc.polyPlane(w=imageSize[0][0]*sizeFactor,h=imageSize[0][1]*sizeFactor,sx=1,sy=1,n='modelPlane',ax=[0,1,0],ch=0)
		mc.hyperShade(modelPlane,assign=material)
		if not mc.objExists('layer_ModelTemplate'): 
			mc.createDisplayLayer(name='layer_ModelTemplate')
			mc.setAttr('layer_ModelTemplate.displayType',2)
		mc.editDisplayLayerMembers('layer_ModelTemplate',modelPlane)
Exemplo n.º 47
0
def saveNukeScript(*args):
    text = cmds.cmdScrollFieldExecuter('copytext', q=1, t=1)
    if not text:
        cmds.confirmDialog(title='Save Nuke Script',
                           message='Nothing script to be saved!',
                           button=['Ok'])
        return
    fileName = cmds.fileDialog(m=1,
                               t='Save Nuke Script As',
                               dm='.nk',
                               dfn='maya2nuke.nk')
    f = file(fileName, 'w')
    f.write(text)
    f.close()
Exemplo n.º 48
0
 def loadfromfile(self):
     filename = cmds.fileDialog()
     fileread = open(filename, 'r')
     filestr = fileread.readlines()
     self.lw.clear()
     self.configs = {}
     n = 0
     for f in range(len(filestr) / 8):
         self.configs[str(filestr[n].rstrip())] = ss_config('')
         self.configs[str(filestr[n].rstrip())].fromstr(filestr[n:n + 8])
         newitem = QtGui.QListWidgetItem()
         newitem.setText(str(filestr[n].rstrip()))
         self.lw.addItem(newitem)
         n += 8
Exemplo n.º 49
0
 def loadBtnCmd(self, *args):
     """Called when the Load Pose button is pressed"""
     filePath = ""
     # Maya 2011 and newer use fileDialog2
     try:
         filePath = cmds.fileDialog2(ff=self.fileFilter, fileMode=1)
     except:
         filePath = cmds.fileDialog(dm="*.%s" % kPoseFileExtension, mode=0)
     # early out of the dialog was canceled
     if filePath is None or len(filePath) < 1:
         return
     if isinstance(filePath, list):
         filePath = filePath[0]
     importPose(filePath)
Exemplo n.º 50
0
def writeXML(data):

    # prepare path, it will print out in the same path of the script.)
    #curPath = os.path.split( __file__ )[0]
    #xmlFile = os.path.join( curPath, fileName )

    results = cmds.fileDialog(m=1, dm="*.xls")
    if (results):
        fileInfo = open(results, "w")

        fileInfo.write(data)
        fileInfo.close()
    else:
        print("Cancelled.")
Exemplo n.º 51
0
	def on_browse( self, *a ):
		curValue = self.getValue()
		ext = curValue.getExtension() or 'txt'

		if curValue.isFile():
			curValue = curValue.up()
		elif not curValue.isDir():
			curValue = Path( cmd.file( q=True, sn=True ) ).up( 2 )

		if not curValue.exists():
			curValue = Path( '' )

		filepath = cmd.fileDialog( directoryMask=curValue / ("/*.%s" % ext) )
		if filepath:
			self.setValue( filepath, True )
Exemplo n.º 52
0
 def loadBtnCmd(self, *args):
     """Called when the Load Light Setup button is pressed, loads light data from file"""
     filePath = ''
     # Maya 2011 and newer use fileDialog2
     try:
         filePath = cmds.fileDialog2(
             ff=self.fileFilter, fileMode=1
         )
     except:
         filePath = cmds.fileDialog(
             dm='*.%s' % kLightFileExtension, mode=0
         )
         # early out of the dialog was canceled
     if filePath is None or len(filePath) < 1: return
     if isinstance(filePath, list): filePath = filePath[0]
     importSetup(filePath)
Exemplo n.º 53
0
	def asciiWrite(self):
		
		# Open a file dialog
		filePath = cmds.fileDialog( m=1 )
		
		if(filePath):
			fileInfo = open(filePath, 'w')
		
			fileInfo.write( "csg\n" )
			
			for node in self.nodes:
				asciiData = self.info[node].asciiInfo()
				fileInfo.write(asciiData)
				fileInfo.write('\n')
			# Call other function to return binary info.
		
			fileInfo.close()
Exemplo n.º 54
0
	def binaryWrite(self):
		
		# Open a file dialog
		filePath = cmds.fileDialog( m=1 )
		
		if(filePath):
			fileInfo = open(filePath, 'wb')
		
			fileInfo.write( "csg" )
			
			for node in self.nodes:
				binData = self.info[node].binaryInfo()
				for bin in binData:
					fileInfo.write(bin)
				# node.asciiInfo()
			# Call other function to return binary info.
		
			fileInfo.close()
Exemplo n.º 55
0
def browseForFile(actionName="Select", fileCommand=None, fileType=None,
                  **kwargs):
    """
    Open a window to browse for a file.
    
    Will use fileBrowserDialog if on windows, fileDialog if not.
    """
    if fileCommand is None:
        def fileCommand(*args, **kwargs): pass
        
    if os.name == 'nt':
        exportFileName = cmds.fileBrowserDialog(fileCommand=fileCommand,
                                                actionName=actionName,
                                                fileType=fileType, **kwargs)
    else:
        exportFileName = cmds.fileDialog(title=actionName)
        fileCommand(exportFileName, fileType)
    return exportFileName   
Exemplo n.º 56
0
 def selectFile(self,forSave):
     '''
     shows UI for file selection; returns file name or None 
     '''
     extensionList = ";".join(map(lambda a: "*.%s" % a,self.ioFormat.recommendedExtensions))
     caption = ('Export as %s' if forSave else 'Import from %s') %self.ioFormat.title
     fileFilter = 'Layer data in %s format (%s);;All Files (*.*)' % (self.ioFormat.title,extensionList)
     
     if Utils.getMayaVersion()>=Utils.MAYA2011:
         result = cmds.fileDialog2(dialogStyle=1,caption=caption,fileFilter=fileFilter,fileMode=0 if forSave else 1,returnFilter=True)
         if result is None:
             return None
         return result[0]
     else:
         result = cmds.fileDialog(title=caption,directoryMask=extensionList,mode=1 if forSave else 0);
         if result=="":
             return None
         
         return result
Exemplo n.º 57
0
 def saveBtnCmd(self, *args):
     """Called when the Save Pose button is pressed"""
     rootNodes = self.getSelection()
     if rootNodes is None:
         return
     filePath = ""
     # Maya 2011 and newer use fileDialog2
     try:
         filePath = cmds.fileDialog2(ff=self.fileFilter, fileMode=0)
     # BUG: Maya 2008 and older may, on some versions of OS X, return the
     # path with no separator between the directory and file names:
     # e.g., /users/adam/Desktopuntitled.pse
     except:
         filePath = cmds.fileDialog(dm="*.%s" % kPoseFileExtension, mode=1)
     # early out of the dialog was canceled
     if filePath is None or len(filePath) < 1:
         return
     if isinstance(filePath, list):
         filePath = filePath[0]
     exportPose(filePath, cmds.ls(sl=True, type="transform"))