徐州专业网站建设公司哪家好,云服务器做视频网站,wordpress 直接连接数据库文件,大丰微信网站开发公司Houdini Python | 笔记合集 - 知乎 Houdini内置三大语言#xff1a; 表达式#xff0c;主要用于节点参数控制#xff0c;可实现跨模块控制#xff1b;vex#xff0c;速度最快#xff08;比表达式和Python快一个数量级#xff09;#xff0c;非常适合密集型计算环境 表达式主要用于节点参数控制可实现跨模块控制vex速度最快比表达式和Python快一个数量级非常适合密集型计算环境应首选python注意用于编写脚本控制pdg实现houdini以外的功能可做表达式和vex(材质除外)大部分事情但最慢此语言可用于自定义窗口、导出数据、加密、抓取网络数据任务发布深度学习等 Houdini中调用Python的方式 Python节点Python ShellPython Source Editor自定义函数模块需保存hip文件节点的Operator Type Properties/Scripts工具架工具Scripts 节点编辑 //创建节点
node.createNode(subnet, subnet_name)
node.createInputNode(0, box)
node.createOutputNode(box)
//节点状态
node.hide(False)
node.setHighlightFlag(False)
node.setTemplateFlag(False)
node.setSelectableTemplateFlag(False)
node.setSelected(False)
node.setUnloadFlag(False)node.setHardLocked(True)
node.setSoftLocked(False)node.setDisplayFlag(True)
node.setRenderFlag(True)node.layoutChildren() //自动排列节点位置相当于Lnode.bypass(True)hou.node(/obj/python).cook(True) //强制重新计算
//节点位置
node.position()
node.setPosition(vector2) //(pos.x()1, pos.y()1)、hou.Vector2(pos.x()1, pos.y()1)
node.move((2,3))
node.moveToGoodPosition()
//获取节点信息
hou.pwd() //获取当前节点
hou.node(.) //获取当前节点node.path() //获取节点的绝对路径node.name()
node.setName(newname)//选择节点
hou.selectedNodes() //返回所选节点的列表
node.setSelected(True) //设置为选择节点
node.setCurrent(True) //设置当前节点为最后选择的节点
//父子节点
node.parent() //父级节点
node.children() //子节点列表
node.allSubChildren() //递归返回所有子节点
node.allNodes() //递归返回所有子节点包括本身
node.allItems() //返回所有子项
node.numItems() //子项数//上游节点
node.inputAncestors()
//连接节点
node.inputs()
node.input(inputindex)
node.outputs()
node.setFirstinput(otherNode)
node.setInput(0, otherNode)//节点类型
hou.nodeType() //HOM Funtion
node.type() //Class Function
node.type().instances()
node.type().name()
node.type().category()
node.changeNodeType(newtype)//节点类型的类别
hou.nodeTypeCategories() //返回类别字典
hou.sopNodeTypeCategory() //返回sop类别//用户数据
node.setUserData(name, value)
node.userDataDict()
node.Data(name)
node.destroyUserData(name)
node.clearUserDataDict()
//注释评论
node.setComment(comment) //设置评论
node.setGenericFlag(hou.nodeFlag.DisplayComment, True) //显示评论
//复制节点
hou.copyNodesTo(nodes, dest)
node.copyTo(dest) 节点参数编辑 //获取参数
hou.parm(path)
hou.parmTuple(path)
node.parm(parm_path)
node.parmTuple(parm_path)
node.parms()
node.parmTuples()
//计算参数
hou.ch(path) //等价于hou.evalParm(path)
hou.evalParm(path)
hou.evalParmTuple(path)
node.evalParm(parm_path)
node.evalParmTuple(parm_path)
node.parm(parm_path).eval()//设置参数
node.setParms(parm_dict)
node.parm(parm_path).set(value)
node.parm(parm_path).rawValue()
node.parm(parm_path).keyframes()
node.parm(parm_path).commponentIndex()
node.parm(parm_path).lock(True)
node.parm(parm_path).pressButton() //调用callback脚本
//ramp参数
ramp_value node.parm(ramp).eval()
ramp_value.lookup(position)//添加ramp参数
node hou.node(/obj/box_object1/null1)
ramp_temp hou.RampParmTemplate(name,label,hou.rampParmType.Color,default_value2)
ramp_parm node.addSpareParmTuple(ramp_temp)
ramp_value hou.Ramp( (hou.rampBasis.Linear, hou.rampBasis.Linear), (0, 1), ((0.0, 1.0, 0.0), (0.0, 0.0, 0.5)) )
ramp_parm[0].set(ramp_value) 几何体对象Geometry hou.SopNode class表示surface节点 hou.Geometry class几何体对象包含定义几何体形状的点或面 //创建线
geo hou.pwd().geometry()point1 geo.createPoint()
point1.setPosition(hou.Vector3(1,2,3))
point2 geo.createPoint()
point2.setPosition(hou.Vector3(0,1,2))poly geo.createPolygon(False)
poly.addVertex(point1)
poly.addVertex(point2)
//geo
geo.points() //返回所有点
geo.prims() //返回所有面
geo.pointAttribs() //返回所有点属性
geo.primAttribs() //返回所有点属性
geo.vertexAttribs() //返回所有点属性geo.addAttrib(type, name, default_value, transform_as_normalFalse, create_local_variableTrue)point.setAttribValue(name_or_attrib, attrib_value)
prim.setAttribValue(name_or_attrib, attrib_value)
vertex.setAttribValue(name_or_attrib, attrib_value)
geo.setGlobalAttribValue(name_or_attrib, attrib_value)
//point
point.number()
point.position()
point.prims()
point.vertices()//prim
prim.number()
prim.points()
prim.vertices()组编辑 //返回对应的所有组
geo.pointGroups()
geo.primGroups()
geo.edgeGroups()
geo.vectexGroups()//创建对应的组
geo.createPointGroup(name, is_orderedFalse)
geo.createPrimGroup(name, is_orderedFalse)
geo.createEdgeGroup(name, is_orderedFalse)
geo.createVertexGroup(name, is_orderedFalse)//查找对应的组
geo.findPointGroup(name)
geo.findPrimGroup(name)
geo.findEdgeGroup(name)
geo.findVertexGroup(name) UI窗口 //显示提示框
hou.ui.displayMessage(text)
hou.ui.displayConfirmation(text)
hou.ui.displayNodeHelp(node.type())
hou.ui.displayFileDependencyDialog()
//输入弹窗
hou.ui.readInput(Insert text) //单行
hou.ui.readMultiInput(message Enter parms:,
input_labels [height,lRadius,uRadius,frequency],
initial_contents [20,10,0,3]) //多行
//文件选择弹窗
hou.ui.selectFile() 函数 //自定义函数
def fun(kwargs):return kwargs
node.asCode() //打印重建此节点所需的代码
str() //转化为字符类型
exec(str) //将字符做为代码运行
locals().get(var) //是否已存在指定的局部变量
//展开字符串内的局部变量或表达式已废弃使用hou.text.expandString
hou.expandString(str)
//在给定帧展开字符串内的局部变量或表达式已废弃使用 hou.text.expandStringAtFrame
hou.expandStringAtFrame(str, frame_number)
//hou.Vector3 class
vector.length()
vector.normalized()
vector.distanceTo(vector3)
vector.dot(vector3)
vector.cross(vector3)
angleTo(vector3)
x()、y()、z()
//获取图像分辨率
imageResolution(image_file_name)
//获取运行的houdini的路径
hou.houdiniPath()
//设置节点的默认表达式语言
node.setExpressionLanguage(hou.exprLanguage.Hscript)
//将节点从指定版本同步到其HDA定义的当前版本
node.syncNodeVersionIfNeeded(from_version)
//加载自定义hda
hou.hda.installFile(hda_file_path)
//存储当前文件
hou.hipFile.save()
//加载一个新文件
hou.hipFile.load() 其他 自定义运行节点代码按钮
在节点创建多行字符串参数语言改为Python创建按钮参数并编写Python调用脚本callback script
//current_node kwargs[node]
//kwargs hou.pwd() kwargs[node]
exec(kwargs[node].parm(code).eval())
//或
exec(hou.pwd().parm(code).eval())
for…in…语句
enumerate()枚举函数