CG流程中, 动画文件经常需要导出相机给灯光使用, 在publish时自动生成一个camera文件, 放到publish/maya/cameras 目录下
写了个shotgun toolkit 插件,导出相机:
20181206174014996.jpg
核心代码:
def finalize(self, settings, item):
publisher = self.parent
path = item.properties.path
path_info = publisher.util.get_file_path_components(path)
publish_folder = path_info["folder"].replace('work','publish').replace('maya','')
publish_folder = os.path.join(publish_folder,"cameras")
self.parent.ensure_folder_exists(publish_folder)
filename = path_info["filename"].replace('Animation','cam').replace('Layout','cam').replace('animation','cam').replace('layout','cam')
filename_path = os.path.join(publish_folder, filename)
cameras = cmds.ls(type=('camera'), l=True,v=1)
#[u'|camMain|camMainShape', u'|camera1|cameraShape1']
if len(cameras) > 0:
cameras_transforms = map(lambda x: cmds.listRelatives(x, parent=True)[0], cameras)
#[u'camera1', u'camMain']
cmds.select(cameras_transforms)
try:
cmds.file(filename_path,force=1,options='v=0;',type='mayaAscii',preserveReferences=1,exportSelected=1)
except Exception as e:
errorTxt = u"%s 生成相机出错 " % e
print(errorTxt)
self.logger.error(errorTxt)
finally:
self._publish_shotgun_data(settings, item, filename_path, filename)
欢迎同行交流 QQ:316853809
原文链接:https://blog.csdn.net/qq_28171389/article/details/84862127
网友评论