您的位置:首页 > 编程语言 > Python开发

Python脚本:一键打开上次Maya崩溃后所保存的临时文件

2013-08-12 20:14 716 查看
这是一个你肯定用得着的脚本,中键拖到shelf上吧~此文来自机器猫的博客:blog.csdn.net/cuckon

在Maya崩溃后如果提示保存到临时目录了,可以打开个新Maya然后执行一下(告小白书:如果拖到shelf了就点shelf就可以了!!shelf就是Maya顶部的那个工具架!!),会自动打开TEMP目录最新的那个临时保存的文件。此文来自机器猫的博客:blog.csdn.net/cuckon

from pymel.core import *
import maya.cmds as mc
import os,glob

class FindFileError(Exception):pass

# find the latest ma
temp_dir = os.environ.get('temp')
latest_ma = str()
latest_time = long(0)
for f in glob.glob(temp_dir+r'\*.ma'):
f_t = long(os.stat(f).st_ctime)
if latest_time < f_t:
latest_time,latest_ma = f_t,f
if latest_time == 0:
raise FindFileError

# open
ret = confirmDialog(title = 'Sure?',
message = 'Are you sure to close current scene and open\n< '+latest_ma.split('\\')[-1]+" >?\nIf file is unsaved then your change would get lost.",
icn = 'question',
button=['Yes','No'],defaultButton='Yes', cancelButton='No', dismissString='No'
)

if ret==u'Yes':
mc.file(latest_ma,open=True,f=True)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: