コード例 #1
0
def deleteOldAutoSaves():

    import maya.cmds as cmds

    import time

    import os.path, time

    save = cmds.autoSave(q=True, enable=True)

    destDir = cmds.autoSave(q=True, destinationFolder=True)

    deleteDays = 3

    if save:

        now = time.time()

        fileCap = now - 60 * 60 * 24 * deleteDays

        files = os.listdir(destDir)

        for file in files:

            fileCreation = os.path.getctime(os.path.join(destDir, file))

            if fileCreation < fileCap:

                os.remove(os.path.join(destDir, file))
コード例 #2
0
def qt_launch_mayapy(mainInstance,**argv):
    from dsk.base.widgets.simpleqt import QtT

    """ important to keep the QApplication creation before importing standalone
    to get a valid Gui QtCore app
    """
    app = QtT.QtCore.QCoreApplication.instance()
    if app == None:
        app = QtT.QtWidgets.QApplication(sys.argv)
    #app.setQuitOnLastWindowClosed(True)
    import maya.standalone as standalone
    standalone.initialize(os.path.basename(sys.argv[0]))
    import maya.cmds as cmds
    cmds.undoInfo(state=False)        # Turn off undo
    cmds.autoSave(enable=False)       # Turn off autosave

    window = mainInstance(None, **argv)

    if window.size().width() <= 0 or window.size().height() <= 0:
        window.resize(500,500)
        window.move(100,100)

    QtT.QtWidgets.QApplication.processEvents()
    window.show()
    window.raise_()
    try:
        sys.exit(app.exec_())
    except:
        pass
    return window
コード例 #3
0
def setAutoSave(*args, **kwargs):
    #set up autosave in username subfolder
    currentWorkspace = mc.workspace(q=1, dir=1)
    localUser = mel.eval("getenv userName")
    autosavePath = "%s%s/autosave/%s" % (currentWorkspace, pg.filefolder,
                                         localUser)
    mc.autoSave(en=1, int=300, lim=1, max=3, dst=1, fol=autosavePath)
    print "AUTOSAVE SET TO: %s" % autosavePath
コード例 #4
0
def deleteOldAutoSaves():
    import maya.cmds as cmds
    import time
    import os.path, time

    save = cmds.autoSave(q=True, enable=True)
    destDir = cmds.autoSave(q=True, destinationFolder=True)
    deleteDays = 3
    if save:
        now = time.time()
        fileCap = now - 60 * 60 * 24 * deleteDays
        files = os.listdir(destDir)
        for file in files:
            fileCreation = os.path.getctime(os.path.join(destDir, file))
            if fileCreation < fileCap:
                os.remove(os.path.join(destDir, file))
コード例 #5
0
def exportXgenMeshes(minTime, maxTime, step):
    cmds.undoInfo(state=False)
    cmds.autoSave(enable=False)
    cmds.saveToolSettings
    cmds.saveViewportSettings
    for i in seq(minTime, maxTime+step+step, step):
        if not i >= maxTime+step:
            print i
            eqValue = round(float(i)-int(i), 1)
            if str(eqValue) == '0.0':
                if os.path.isdir(exportPath):
                    print str("value: ") + str(eqValue)
                    print 'frame, folder exists'
                    makeExport(str(int(i)))
                else:
                    os.makedirs(str(exportPath))
                    print str("value: ") + str(eqValue)
                    print 'frame, folder created'
                    makeExport(str(int(i)))
            elif str(eqValue) == '1.0':
                if os.path.isdir(exportPath):
                    print str("value: ") + str(eqValue)
                    print 'frame, folder exists'
                    makeExport(str(int(i+1)))
                else:
                    os.makedirs(str(exportPath))
                    print str("value: ") + str(eqValue)
                    print 'frame, folder created'
                    makeExport(str(int(i+1)))
            else:
                if os.path.isdir(exportPath):
                    print str("value: ") + str(eqValue)
                    print 'subframe, folder exists'
                    makeExport(str(i))
                else:
                    os.makedirs(str(exportPath))
                    print str("value: ") + str(eqValue)
                    print 'subframe, folder created'
                    makeExport(str(i))
        else:
            pass
コード例 #6
0
     "default":False
 },{ "name":"autoJumpToSelectedKey",
     "command":"jumpToSelectedKey.togglejumpToSelectedKey(onOff)",
     "default":False
 },{ "name":"autoSmartSnapKeys",
     "command":"self.autoSmartSnapKeys.switch(onOff)",
     "default":False
 },{ "name":"animationCrashRecovery",
     "command":"animationCrashRecovery.switch(onOff)",
     "default":True
 },{ "name":"selectionCounter",
     "command":"self.selectionCounter.switch(onOff)",
     "default":True
 },{ "name":"autoSave",
     "command":"cmds.autoSave(enable=onOff)",
     "default":cmds.autoSave(query=True, enable=True)
 },{ "name":"topWaveform",
     "command":"commandsMod.topWaveform(onOff)",
     "default":True
 },{ "name":"playbackAllViews",
     "command":"onOff = 'all' if onOff else 'active'; cmds.playbackOptions(view=onOff)",
     "default":True
 },{ "name":"displayAffected",
     "command":"cmds.displayAffected(onOff)",
     "default":False
 },{ "name":"undoQueue",
     "command":"if onOff: cmds.undoInfo( state=True, infinity=False, length=300)",
     "default":True
 },{ "name":"scrubbingUndo",
     "command":"commandsMod.scrubbingUndo(onOff)",
     "default":True
コード例 #7
0
ファイル: generalToolsUI.py プロジェクト: Italic-/maya-prefs
     "default":False
 },{ "name":"autoJumpToSelectedKey",
     "command":"jumpToSelectedKey.togglejumpToSelectedKey(onOff)",
     "default":False
 },{ "name":"autoSmartSnapKeys",
     "command":"self.autoSmartSnapKeys.switch(onOff)",
     "default":False
 },{ "name":"animationCrashRecovery",
     "command":"animationCrashRecovery.switch(onOff)",
     "default":True
 },{ "name":"selectionCounter",
     "command":"self.selectionCounter.switch(onOff)",
     "default":True
 },{ "name":"autoSave",
     "command":"cmds.autoSave(enable=onOff)",
     "default":cmds.autoSave(query=True, enable=True)
 },{ "name":"topWaveform",
     "command":"commandsMod.topWaveform(onOff)",
     "default":True
 },{ "name":"playbackAllViews",
     "command":"onOff = 'all' if onOff else 'active'; cmds.playbackOptions(view=onOff)",
     "default":True
 },{ "name":"displayAffected",
     "command":"cmds.displayAffected(onOff)",
     "default":False
 },{ "name":"undoQueue",
     "command":"if onOff: cmds.undoInfo( state=True, infinity=False, length=300)",
     "default":True
 },{ "name":"scrubbingUndo",
     "command":"commandsMod.scrubbingUndo(onOff)",
     "default":True
コード例 #8
0
#get a list of the workspaces/projects
listWS = cmds.workspace(listWorkspaces = True)
for wsp in listWS:
  print wsp

# change Maya to use a workspace if it exists
#use a try/except catch
try:
  cmds.workspace('WorkspaceName', openWorkspace=True)
except:
  raise Exception("Project WorkspaceName doesn't exist!")

#retrieve root location of current project setup in Maya
workspaceFolder = cmds.workspace( q=True, rd=True)

#write log files for a project 
logPath = cmds.workspace ( q=True, rd=True ) + 'data'

#set up frame rates and resolutions for projects
#insert this into the userSetup.py file for automatic loading
cmds.currentUnit( linear='m' ) #sets the units to meters
cmds.currentUnit( time='film') #sets the frame rate to 24fps

#set render resolution to 720p
cmds.setAttr( 'defaultResolution.width', 1280 )
cmds.setAttr( 'defaultResolution.width', 720 )

#enable autosave every 300 seconds/5minutes
cmds.autoSave( int=300, dst=0, prm=False, en=True, lim=True, max=10 )
コード例 #9
0
#get a list of the workspaces/projects
listWS = cmds.workspace(listWorkspaces=True)
for wsp in listWS:
    print wsp

# change Maya to use a workspace if it exists
#use a try/except catch
try:
    cmds.workspace('WorkspaceName', openWorkspace=True)
except:
    raise Exception("Project WorkspaceName doesn't exist!")

#retrieve root location of current project setup in Maya
workspaceFolder = cmds.workspace(q=True, rd=True)

#write log files for a project
logPath = cmds.workspace(q=True, rd=True) + 'data'

#set up frame rates and resolutions for projects
#insert this into the userSetup.py file for automatic loading
cmds.currentUnit(linear='m')  #sets the units to meters
cmds.currentUnit(time='film')  #sets the frame rate to 24fps

#set render resolution to 720p
cmds.setAttr('defaultResolution.width', 1280)
cmds.setAttr('defaultResolution.width', 720)

#enable autosave every 300 seconds/5minutes
cmds.autoSave(int=300, dst=0, prm=False, en=True, lim=True, max=10)
コード例 #10
0
import maya.cmds as cmds
コード例 #11
0
# Shelf button to toggle Maya autosaving.

from maya.cmds import autoSave
import sys

if autoSave(q=1, en=1):
    autoSave(en=False)
    sys.stdout.write('Auto save disabled. Living dangerously ;)')
else:
    autoSave(en=True)
    sys.stdout.write('Auto save enabled. Laughs at Maya crashes.')
コード例 #12
0
ファイル: AutoSave.py プロジェクト: remusvrm/scripts
# Create autoSave script

import maya.cmds as mc

intervalSeconds = 600
folderDestination = "D:/Python/My scripts/testautosave"

mc.autoSave( enable=True, interval=intervalSecunde, prompt=False, destination=1, folder=folderDestination, perform=True )
コード例 #13
0
    def execute(self, engine, **kwargs):
        """
        Gets executed when a Toolkit engine has fully initialized.
        At this point, all applications and frameworks have been loaded,
        and the engine is fully operational.
        """
        if engine.name == "tk-nuke":
            import nuke
            nuke.tprint("Nuke settings define in core\hooks\engine_int.py")
            nroot = nuke.Root()

            # Get SG
            ctx = engine.context
            project = ctx.project
            sg = engine.shotgun

            filters = [['sg_status', 'in', ['Active', 'Development']],
                       ['id', 'is', project['id']]]
            fields = [
                'name', 'sg_format_width', 'sg_format_height',
                'sg_delivery_format_width', 'sg_delivery_format_height',
                'sg_format_pixel_aspect_ratio', 'sg_pixel_aspect_ratio',
                'sg_frame_rate', 'sg_short_name'
            ]
            project_info = sg.find_one('Project', filters, fields)
            if project_info:
                if not (project_info['sg_frame_rate']
                        and project_info['sg_format_width']
                        and project_info['sg_format_height']
                        and project_info['sg_format_pixel_aspect_ratio']
                        and project_info['sg_short_name']):
                    nuke.tprint(
                        "!!!Missing important Project info to update Nuke. Please inform production!!!"
                    )
                    nuke.tprint("Project settings : ")
                    nuke.tprint("- Name: %s " % str(project_info['name']))
                    nuke.tprint(
                        "- Format: %s x %s : %s" %
                        (str(project_info['sg_format_width']),
                         str(project_info['sg_format_height']),
                         str(project_info['sg_format_pixel_aspect_ratio'])))
                    nuke.tprint("- FPS: %s" %
                                str(project_info['sg_frame_rate']))
                    nuke.tprint("- ShortName: %s" %
                                str(project_info['sg_short_name']))
                    if (project_info['sg_delivery_format_width']
                            and project_info['sg_delivery_format_height']):
                        nuke.tprint(
                            "- Delviery format: %s x %s" %
                            (str(project_info['sg_delivery_format_width']),
                             str(project_info['sg_delivery_format_height'])))

                else:
                    nroot.knob('fps').setValue(
                        float(project_info['sg_frame_rate']))
                    nuke.knobDefault("Root.fps", project_info['sg_frame_rate'])
                    nuke.addFormat(
                        "%s %s %s %s" %
                        (str(project_info['sg_format_width']),
                         str(project_info['sg_format_height']),
                         str(project_info['sg_format_pixel_aspect_ratio']),
                         (project_info['sg_short_name'] + "_" +
                          str(project_info['sg_format_width']))))
                    nuke.knobDefault("Root.format",
                                     (project_info['sg_short_name'] + "_" +
                                      str(project_info['sg_format_width'])))

                    nuke.tprint("Project settings applied:")
                    nuke.tprint("- Name: %s " % project_info['name'])
                    nuke.tprint(
                        "- Format: %s x %s : %s" %
                        (str(project_info['sg_format_width']),
                         str(project_info['sg_format_height']),
                         str(project_info['sg_format_pixel_aspect_ratio'])))
                    nuke.tprint("- FPS: %s" % project_info['sg_frame_rate'])
                    nuke.tprint("- ShortName: %s" %
                                str(project_info['sg_short_name']))
            else:
                nuke.tprint(
                    'Issue retrieving format settings for Project from SG.')

        elif engine.name == "tk-desktop":

            self.logger.debug("Desktop engine init. Running processes.")
            try:
                # Get the machine info
                user_id = engine.context.user['id']
                machine_name = os.environ['COMPUTERNAME']
                ip_address = socket.gethostbyname(socket.gethostname())
                self.logger.debug("User ID %s has machine %s with IP of %s" %
                                  (str(user_id), machine_name, ip_address))

                # Submit info to SG
                sg = engine.shotgun
                data = {
                    'sg_machine': machine_name,
                    'sg_ip_address': str(ip_address)
                }
                result = sg.update('HumanUser', user_id, data)
                if result:
                    self.logger.debug("Updated the SG User info.")

            except:
                self.logger.debug("Problem updating the SG User info.")

        elif engine.name == "tk-maya":
            import maya.cmds as cmds

            # enable rolling autosave
            cmds.autoSave(enable=1,
                          interval=1800,
                          destination=1,
                          folder="H:/MAYA_TEMP/autosaves/",
                          limitBackups=1)

        else:
            self.logger.debug("Could not get engine!")
コード例 #14
0
    def __init__(cls):
        # undo
        cmds.undoInfo(state=True, infinity=True)

        # soft edge display for polygon geometry
        # cmds.polyOptions(np = True, se = True)

        # view cube
        cmds.viewManip(v=True)

        # manipulator line size
        cmds.manipOptions(ls=1)

        # auto save
        cmds.autoSave(en=True)
        cmds.autoSave(int=(60 * 30))
        cmds.autoSave(lim=True)
        cmds.autoSave(max=3)
        cmds.autoSave(dst=1)
        user = os.environ.get('USERNAME')
        cmds.autoSave(fol='C:/Users/%s/AppData/Local/Temp' % (user))

        # File Dialog Style
        cmds.optionVar(iv=('FileDialogStyle', 1))

        if cmds.window(cls.widgets['win'], exists=True):
            cmds.deleteUI(cls.widgets['win'])
        cls.ui()
コード例 #15
0
ファイル: autoSave.py プロジェクト: MakChiKin/python_test
import maya.cmds as cmds

#将自动保存之间的间隔设置为5分钟
cmds.autoSave(int=300)

# 查询自动保存间隔
cmds.autoSave(q=True, int=True)
# Result: 300.0 #