在做绑定时, 由于设置的特殊性,不用频繁的改maya reference的文件, 需要一个不带版本号的模型文件参考,需要扩展toolkit开发插件,触发事件在publish完成后的finalize上来执行
def finalize(self, settings, item):
work_file = item.properties["path"]
work_filename = os.path.basename(work_file)
work_path = os.path.dirname(work_file)
mode = item.context.task['name'].lower()
# print(work_path, dirpath,filename,mode)
if 'model' in mode and 'environment' not in work_file.lower():
#角色道具同时生成一个不带版本号和人名的文件
filenamelist = work_filename.split('_')
extension = os.path.splitext(work_filename)[1]
newfile = "%s_%s_%s%s" % (filenamelist[0], filenamelist[1], filenamelist[2],extension)
publish_folder = work_path.replace('work','publish')
publish_file = os.path.join(publish_folder,newfile)
publish_folder = os.path.dirname(publish_file)
ensure_folder_exists(publish_folder)
copy_file(work_file, publish_file)
print('%s to %s' % (work_file,publish_file))
#####################################
#写入shotgun
publisher = self.parent
publish_dependencies = self.get_publish_dependencies(settings, item)
self.logger.info("Registering publish...")
publish_data = {
"tk": publisher.sgtk,
"context": item.context,
"comment": item.description,
"path": publish_file,
"name": newfile,
qq:316853809 欢迎CG同行交流