Пример #1
0
def loadTestRoom():

    needSave = cmds.file(q=True, modified=True)
    testroomfile = mel.eval('getenv SLiBLib;') + '/scene/SLiB_ShaderTestRoom_hdri.ma'
    testroomdestination = cmds.workspace(query = True, fullName = True)
    hdrifile = mel.eval('getenv SLiBLib;') + '/scene/TestRoom.hdr'
    bgfile = mel.eval('getenv SLiBLib;') + '/scene/BG_grey.png'
    checkerfile = mel.eval('getenv SLiBLib;') + '/scene/Checker.png'
    
    if needSave:
        cmds.SaveScene()
    else:
        pass
    
    cmds.file( f=True, new=True )
    cmds.file( testroomfile, o=True )
    cmds.setAttr('redshiftDomeLightShape1.tex0', str(hdrifile), type="string")
    cmds.setAttr('redshiftDomeLightShape1.tex1', str(bgfile), type="string")
    cmds.setAttr('RS_CheckerBall_File01.fileTextureName', str(checkerfile), type="string")
    cmds.setAttr('RS_CheckerRoom_File01.fileTextureName', str(checkerfile), type="string")
    t = cmds.date()
    xsplit = t.split('/')
    y = xsplit[-1]
    name = 'RS_Testroom_' + t + '.ma'
    savename1 = name.replace (" ", "_")
    savename2 = savename1.replace ("/", "")
    savename3 = savename2.replace (":", "")
    cmds.file( rename=savename3 )
    cmds.file(save=True, type='mayaAscii' )
Пример #2
0
def checkState():
    # check if there are unsaved changes
    fileCheckState = cmds.file(q=True, modified=True)

    # if there are, save them first ... then we can proceed 
    if fileCheckState:
        cmds.SaveScene()
Пример #3
0
def run(*args, **kwargs):
    #required scenes folder
    folder = pg.filefolder

    #run file dialog query 1=open file
    path = gfp.getFilePath(1)

    if path:
        #derive new workspace from selected file path
        if "/%s/" % folder in path:
            workspace = path.split(folder)[0]
        else:
            workspace = "/".join(path.split("/")[:-2])
        #try to list subdirectories
        subDir = []
        try:
            subDir = os.listdir(workspace)
        except:
            mc.warning("%s is not valid file directory" % workspace)
        #check for required file
        if folder not in subDir:
            mc.confirmDialog(
                m=
                "Selected File Not In Project Directory. Please Save Version Into Project Directory.",
                b="Ok")
        else:
            #open selected file
            print "SETTING PROJECT: %s" % workspace
            mc.workspace(workspace, o=1)
            mc.workspace(dir=workspace)

        #check if scene has been modified
        if mc.file(q=1, modified=1):
            confirm = mc.confirmDialog(t="Save Scene?",
                                       m="Save Changes?",
                                       b=['Yes', 'No', 'Cancel'],
                                       db="Yes",
                                       ds="Dismissed",
                                       cb="Cancel")
            if confirm == "Yes":
                mc.SaveScene()
                mc.file(path, o=1, iv=1)
            elif confirm == "No":
                mc.file(path, o=1, f=1, iv=1)
            else:
                print "Nothing Saved"
        else:
            #open selected file if it exists
            if mc.file(path, q=1, ex=1):
                mc.file(path, o=1, iv=1)
                #enable autosave on scene open
                setAutoSave()
            else:
                pass
    else:
        pass
    """
Пример #4
0
	def file_save(self):
		""" Save the current file.
			If saving for first time take over and show custom dialog.
		"""
		if self.get_current_name():  # Scene has been saved before
			mc.SaveScene()

		else:  # Scene not yet saved
			self.file_save_dialog()
Пример #5
0
	def file_save_as(self, filepath):
		""" Save the current file to the specified filepath.
			If the destination dir doesn't exist, create it.
			TODO: prompt if save will overwrite existing file
			TODO: add updateRecentFiles flag
		"""
		dirname = os.path.dirname(filepath)
		if not os.path.isdir(dirname):
			os_wrapper.createDir(dirname)
		mc.file(rename=filepath)
		mc.SaveScene()
		recent_files.recents.put(filepath)
		return True
Пример #6
0
def checkState():
    # check if there are unsaved changes
    fileCheckState = cmds.file(q=True, modified=True)

    # if there are, save them first ... then we can proceed
    if fileCheckState:
        # This is maya's native call to save, with dialogs, etc.
        # No need to write your own.
        if dlg.warning("warning", "Scene Not Saved",
                       "Scene Not Saved, Do you want to save it first?"):
            cmds.SaveScene()
        pass
    else:
        pass
Пример #7
0
def saveSceneAssembly(*args):

	'''
	sel=cmds.ls(sl=True)
	multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)"
	filename=cmds.fileDialog2(fileFilter=multipleFilters, dialogStyle=2)
	print filename
	'''
	cmds.SaveScene() # That is the answer what I search a long long time. 
	'''
	cmds.file(rename=filename)
	cmds.file(save=True,type="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)")
	'''
	'''
Пример #8
0
    def load(self, context, name, namespace, options):
        from maya import cmds

        if cmds.file(query=True, modified=True):

            _title = "Warning: Scene Not Saved"
            _message = "Save changes to untitled scene?"
            _save = "Save"
            _keep = "Don't Save"
            _stop = "Cancel"
            result = cmds.confirmDialog(title=_title,
                                        message=_message,
                                        button=[_save, _keep, _stop],
                                        defaultButton=_stop,
                                        cancelButton=_stop,
                                        dismissString=_stop)
            if result == _save:
                if avalon.maya.is_locked():
                    _message = "Scene is locked, please save under a new name."
                    cmds.confirmDialog(title="",
                                       message=_message,
                                       button=["OK"],
                                       defaultButton="OK",
                                       cancelButton="OK",
                                       dismissString="OK")
                    return

                # Save file if not locked
                cmds.SaveScene()
                if cmds.file(query=True, modified=True):
                    # Possible pressed the Cancel button in SaveAs Dialog
                    self.log.error("Modification unsaved, abort opening "
                                   "work scene.")
                    return

            elif result == _keep:
                pass

            elif result == _stop:
                return

        cmds.file(modified=False)

        self.open_source_from_context(context)
Пример #9
0
 def get_jobdata(self):
     if self.scene_name == '':
         raise ValueError("Current Maya scene has not been saved to disk.")
     
     pending_changes = cmds.file(query=True, modified=True)
     if not pending_changes:
         return self.scene_name, [self.scene_name]
     options = {
         'save': "Save and continue",
         'nosave': "Continue without saving",
         'cancel': "Cancel"
     }
     answer = cmds.confirmDialog(title="Unsaved Changes",
                                 message="There are unsaved changes. Continue?",
                                 button=options.values(),
                                 defaultButton=options['save'],
                                 cancelButton=options['cancel'],
                                 dismissString=options['cancel'])
     if answer == options['cancel']:
         raise Exception("Submission cancelled")
     if answer == options['save']:
         cmds.SaveScene()
     return self.scene_name, [self.scene_name]
Пример #10
0
def P5exporter():

    ############# Check if scene is set to Meteres #########################
    if cmds.currentUnit(query=True, linear=True) == 'm':

        ###### Makes sure the scene is saved ####################
        if cmds.file(q=True, modified=True):
            cmds.SaveScene()

        PLUGIN = 'fbxmaya.mll'

        ###################### Find scene path ##################
        if cmds.file(q=True, sn=True):

            maSaveLocation = cmds.file(q=True, sn=True)
            convertedPath = os.path.dirname(os.path.abspath(maSaveLocation))

        else:
            cmds.warning('Scene is still not saved')

        #################### Convert MA save path to new FBX path ##########

        expPath = GetPath.GetPath('fbx', maSaveLocation)
        expPathMel = expPath.replace('\\', '/')

        ############## Duplicate, combine and rename ###################
        def duplicateCombine(selection, name):
            children = cmds.listRelatives(selection, path=True)
            if len(children) == 1:
                cmds.duplicate(children[0], n=name)
                cmds.parent(name, 'LOD0_')
            else:
                cmds.delete(cmds.polyUnite(cmds.duplicate(children), n=name),
                            ch=True)
                cmds.parent(name, 'LOD0_')

        ####################### Pivot Check ############################
        def pivotCheck(selection):
            for i in selection:
                if not cmds.xform(
                        '%s.scalePivot' %
                    (i), q=True, ws=True, t=True) == [0.0, 0.0, 0.0]:
                    cmds.warning(
                        'One or more pivots are not in the center of the scene'
                    )
                    return True

        myObjects = []

        mySelection = cmds.ls(selection=True, long=True)

        expDict = {}

        currentObjects = mySelection
        finished = False

        if currentObjects:
            while finished == False:
                currentObjectsList = []
                for obj in currentObjects:
                    children = cmds.listRelatives(obj,
                                                  type='transform',
                                                  fullPath=True)
                    if children == None:
                        myObjects.append(obj)
                        finished = True
                    else:
                        for child in children:
                            currentObjectsList.append(child)

                if currentObjectsList == []:
                    finished = True
                else:
                    currentObjects = currentObjectsList

            listCheck = []

            for i in myObjects:
                x = myObjects.index(i)
                splitName = myObjects[x].split('|')[1:4]
                print splitName
                newName = '|'.join(splitName)
                toFullName = '|' + newName
                FBXName = re.sub(
                    '__*', '_', '%s_%s' % (splitName[1], splitName[2])
                )  #re.sub removes any duoble accurences of '_'
                listForExpFunction = (toFullName, FBXName)
                expDict[FBXName] = toFullName
                if not listForExpFunction[0] in listCheck:
                    listCheck.append(listForExpFunction[0])
                    if not os.path.isdir(os.path.abspath(expPath)):
                        os.makedirs(os.path.abspath(expPath))

        successful = None
        successfulItems = []
        for key in expDict:

            mel.eval('FBXResetExport')

            ########### Set FBX export settings ########################
            mel.eval('FBXExportTangents -v true')
            mel.eval('FBXExportSmoothingGroups -v true')
            mel.eval('FBXExportInputConnections -v 0')
            mel.eval('FBXExportConvertUnitString "cm"')
            mel.eval('FBXExportUpAxis y')
            mel.eval('FBXExportFileVersion "FBX201400/201500"')
            mel.eval('FBXExportInAscii -v true')
            successful = True
            successfulItems.append(key)
            duplicateCombine(expDict[key],
                             key)  # Duplicates and merges the models
            cmds.select(key)  # Select new merged object
            cmds.FBXExport('-file', expPathMel + '/' + key + '.fbx',
                           '-s')  # Export selected object
            cmds.delete(key)  # delete Duplicate.
            print('Successfully exported ' + key + '.fbx to ' + expPath)

        if successful:
            successfulMessage = ('\n'.join(successfulItems))
            confirmDialog = cmds.confirmDialog(
                messageAlign='center',
                title='Successful export',
                message='Successfully exported objects:\n%s' %
                (successfulMessage),
                cancelButton='OK',
                button=['OK', 'Open Folder'],
                defaultButton='OK')
            if confirmDialog == 'Open Folder':
                os.startfile(expPath)
    else:
        cmds.warning('The scene scale is not set to meter')


#reload(P5_tools.P5FBXexporter)
Пример #11
0
def save_scene():
    cmds.SaveScene()
Пример #12
0
import maya.cmds as mc

# check if there are unsaved changes
fileCheckState = mc.file(q=True, modified=True)

# if there are, save them first ... then we can proceed 
if fileCheckState:
  print 'Need to save.'
  # This is maya's native call to save, with dialogs, etc.
  # No need to write your own.
  mc.SaveScene()
  pass
else:
  print 'No new changes, proceed."
  pass
Пример #13
0
def save_current_maya_scene():
    '''
    Saves current Maya scene using standard save command
    '''
    logger.debug("Saving Maya scene...")
    cmds.SaveScene()