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

这是一个你肯定用得着的脚本,中键拖到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)


评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值