Houdini python批量导入abc
在项目中经常与遇到有大量的abc文件需要导入的问题,这个时候就需要批量导入abc来完成后面的工作
第一次写小工具,离高手还很远,继续学习中
直接上代码
去博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片
.
import os
import re
import hou
input = hou.ui.readInput("Please input a path", ('OK', 'Cancle'))
if input[0] == 0:
path = input[1]
print path
dirList = os.listdir(path)
root = hou.node("/obj")
null = root.createNode('null', 'root')
null.parm('scale').set(0.01)
aleDirs = [x for x in dirList if x.endswith(".abc")]
for dir in aleDirs:
pattern = re.compile(r'cam', re.I)
m = pattern.search(dir)
name = dir.split('.', 1)[0]
if bool(m) == False:
geo = root.createNode("geo", name)
geo.setInput(0, null)
ale = geo.createNode('alembic', name)
fullPath = path + "/" + dir
ale.parm("fileName").set(fullPath)
nullNode = geo.createNode('null', '__OUT')
nullNode.setInput(0, ale, 0)
nullNode.setRenderFlag(True)
nullNode.setDisplayFlag(True)
nullNode.moveToGoodPosition()
if bool(m) == True:
aleCam = root.createNode("alembicarchive", node_name = name)
aleCam.moveToGoodPosition()
aleCam.setFirstInput(null)
filePath = path + "/" + dir
aleCam.parm('fileName').set(filePath)
aleCam.parm('buildHierarchy').pressButton()
nullNode.moveToGoodPosition()