赞
踩
最近接到个需求:在创建EFX文件时,自动加载动画出的缓存abc文件+相机, 不用手动一个个的载入,还容易出错
在CGTeamwork里打开对应的镜头,下面的文件列表显示相机和角色文件, 之前特效师手动一个个的参考到houdini文件上去的, 很费劲还容易漏掉,自动化工具需要自动把它们加载到houdin上去。
原理:cgteamwork先调用start, 找到当前的镜头号,给到plugin, plugin算到路径下的abc列表,把列表文件赋给 /obj
houdini_open_start.py
import os,glob import sys import houdini_plugin G_NukePlugin_Path = os.path.dirname( sys.argv[0] ) sys.path.append( G_NukePlugin_Path ) try: from PySide2.QtCore import * except: from PySide.QtCore import * os.environ['QTWEBENGINEPROCESS_PATH'] = '' appPath = QCoreApplication.applicationFilePath() sys.path.append(r'C:/CgTeamWork_v7/bin/base') import cgtw2 t_tw = cgtw2.tw() def mina(): db = sys.argv[1] module = sys.argv[2] taskname = sys.argv[3] taskid = sys.argv[4] taskid = taskid.split(":")[1] module="shot" field_sign_list=t_tw.task.fields(db,module)[:50] filter_list=[] id_list=[taskid] tasks = t_tw.task.get(db, module, id_list, field_sign_list, limit='5000', order_sign_list=[]) if tasks: task = tasks[0] # print(122323,task) houdini_plugin.create_alembic_node(task["eps.entity"], task['shot.entity'])#source_name mina()
houdini_plugin.py
import os,glob import sys import hou def create_alembic_node(ep, shot): alembic_dir = "S:/Projects/NL/QHMX/{}/Shot/{}/Animation/approve/cache/".format(ep, shot) if not os.path.exists(alembic_dir): return folder = glob.glob(alembic_dir+r"alembic/*.abc") geoNode = hou.node("/obj/").createNode("geo", "abc") geoNode.setColor(hou.Color(1,0,0)) geoNode.setPosition([3,0]) # geoNode.setDisplayFlag(False) # geoNode.setSelectableInViewport(False) scaleNode = hou.node("obj").createNode("null", "Scale") scaleNode.setColor(hou.Color(1,0,0)) scaleNode.setPosition([0,2]) for file in folder: file = file.replace("\\","/") filename = os.path.basename(file).replace(".abc","") if filename!="light": abcNode = geoNode.createNode("alembic", filename) abcNode.parm("fileName").set(file) abcNode.moveToGoodPosition() # abcNode.layoutChildren() else: lightNode = hou.node("/obj/").createNode("geo", "light") lightNode.setColor(hou.Color(1,0,0)) lightNode.setPosition([1,0]) abcNode = lightNode.createNode("alembic", filename) abcNode.parm("fileName").set(file) abcNode.moveToGoodPosition() lightNode.setFirstInput(scaleNode) geoNode.setFirstInput(scaleNode) folder = glob.glob(alembic_dir+r"camera/*.abc") file = folder[0].replace("\\","/") filename = os.path.basename(file).replace(".abc","") node = hou.node('obj') camnode = node.createNode('alembicarchive',filename) camnode.setColor(hou.Color(1,0,0)) camnode.parm('fileName').set(file) camnode.setPosition([-3,0]) camnode.setFirstInput(scaleNode) camnode.parm('buildHierarchy').pressButton() parent = camnode.parent() box = parent.createNetworkBox() box.addItem(camnode) box.addItem(geoNode) box.addItem(scaleNode) node = hou.node('/obj/NL_{ep}_{shot}_Cam/NL_{ep}_{shot}_Cam/NL_{ep}_{shot}_CamShape'.format(ep=ep, shot=shot)) node.parm("resx").set(1920) node.parm("resy").set(1080) fileNode = hou.node('/obj/').createNode('geo', 'filecache') fileNode.moveToGoodPosition() fileNode.setColor(hou.Color(0,0,1)) # fileNode.setPosition([0,3]) filecache = fileNode.createNode('filecache', 'filecache1') filecache.parm('filemethod').set(1) path = 'S:/Cache/NL/QHMX/{}/{}/`opname("..")`/$OS/$OS.$F4.bgeo.sc'.format(ep, shot) filecache.parm('file').set(path) box.addItem(fileNode)
大大降低手工操作,完成!
link q : 316853809
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。