Maya选择相机另存maya文件

[up主专用,视频内嵌代码贴在这]

Maya选择相机另存maya文件

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
# -*- coding: utf-8 -*-
"""
@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:
# 结果: [u'Ep022_sc005_003_201_248_cam:Ep022_sc005_003_201_248_camShape'] #
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_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)#fade = True,
else:
print(u"灯光文件 {} 已经存在".format(lgt_path_f))
cmds.inViewMessage(amg = u'灯光文件已经存在:'+'<hl>' +lgt_name+ '<hl>' , pos = 'botRight' , bkc = 0x00000000 , dragKill = True)
# 在 Maya 中显示消息窗口
cmds.confirmDialog(title=u'提示', message=u"灯光文件 {} 已经存在无法进行保存".format(lgt_path_f), button=[u'好的'])