1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| """ @Author: Meng """ import os, re from pymel.core import * from maya.cmds import *
import maya.OpenMaya as OpenMaya
def saveas_AHZ(): selection = cmds.ls(selection=True, dag=True, type='camera') if not selection: info = u'请先选择一个摄像机进行镜号信息采集!' cmds.warning(info) cmds.confirmDialog(title=u'提示', message=u'请先选择一个摄像机进行镜号信息采集!', button=[u'好的']) else: selected_list = selection[0].split("_") lgt_name = 'AHZ_' + '_'.join([x for x in selected_list[:3]]) + '_lgt_v001.ma' lgt_path = "Y:/AHZ/EP022/Lighting/File/" + selected_list[1] + "/" + selected_list[2] lgt_path_f = lgt_path+'/'+lgt_name if not os.path.exists(lgt_path_f): os.makedirs(lgt_path) print("文件夹 {} 已创建".format(lgt_path)) cmds.file(rename=lgt_path_f) cmds.file(save=True) cmds.inViewMessage(amg = u'另存灯光文件:'+'<hl>' +lgt_path_f+ '<hl>' , pos = 'botRight' , bkc = 0x00000000 , dragKill = True) else: print(u"灯光文件 {} 已经存在".format(lgt_path_f)) cmds.inViewMessage(amg = u'灯光文件已经存在:'+'<hl>' +lgt_name+ '<hl>' , pos = 'botRight' , bkc = 0x00000000 , dragKill = True) cmds.confirmDialog(title=u'提示', message=u"灯光文件 {} 已经存在无法进行保存".format(lgt_path_f), button=[u'好的'])
|