Access Nodes through Python and Command Line

   554   0   1
User Avatar
Member
3 posts
Joined: April 2019
Offline
I'm trying to write a Python script that access and setups nodes that are already inside a .hipnc file.

I ran a small test that creates a parameter to a node that is already in the tree. I've used Python Source Editor from inside the Houdini File.
It works as expected.

However, when trying the same using command line to add the parameter to the node that is already in the tree, I get an error. Looks like I can't access the nodes that area inside the project.
Is there a way to do this or am I doing something wrong?

The command line:
hython "D:\Tori\testaccessfilenode.py" "pointcloud-test.hipnc"The error:
Traceback (most recent call last):
File "D:\Tori\testaccessfilenode.py", line 4, in <module>
g = n.parmTemplateGroup()
AttributeError: 'NoneType' object has no attribute 'parmTemplateGroup'

import hou
n = hou.node("/obj/box_object1/box1")
# get existing list of parameters for the specified node
g = n.parmTemplateGroup()

# define new float parameter ("id", "Label", components/input fields, default values)
p = hou.FloatParmTemplate("myParm", "My Parameter", 3, default_value=[1, 1, 1])

# append the new parameter to the list
g.append(p)

# apply changes
n.setParmTemplateGroup(g)
Edited by schmigel - May 5, 2021 13:37:38
  • Quick Links