shotgun 相机导出插件开发

CG流程中, 动画文件经常需要导出相机给灯光使用, 在publish时自动生成一个camera文件, 放到publish/maya/cameras 目录下

写了个shotgun toolkit 插件,导出相机:
在这里插入图片描述

核心代码:

    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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值