让cgteamwork自动为Houdini载入相机,角色道具的abc文件
一 需求
最近接到个需求:在创建EFX文件时,自动加载动画出的缓存abc文件+相机, 不用手动一个个的载入,还容易出错
二 过程/效果
在CGTeamwork里打开对应的镜头,下面的文件列表显示相机和角色文件, 之前特效师手动一个个的参考到houdini文件上去的, 很费劲还容易漏掉,自动化工具需要自动把它们加载到houdin上去。
- 配置houdini启动器,在参数栏上写入houdini_open_start.py路径, win路径填houdini安装路径,其他的视情况填
- 点击cgteamwork镜头任务右上角的houdini关联, 自动打开houdini软件
- houndin相机自动载入起始帧,统一的命名。 资产abc自动放到一个组内
- 自定义一个统一的输出节点, 以免输出路径不统一
三 代码
原理: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