Couple of basic pyhton questions

   26411   48   1
User Avatar
Member
1914 posts
Joined: Nov. 2006
Offline
Look at hou.Node.addSpareParmTuple and hou.HDADefinition.addParmTuple.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
864 posts
Joined: Oct. 2008
Offline
Great that works. There is a minor problem with the layout if I use a folder.

What is going on there???

obj = hou.node(“/obj”)
camera_node = obj.createNode(“cam”, “my_camera”)
hou_node = camera_node
myTemplate = hou.FloatParmTemplate( “myparm”, “My Parm”, 1, default_value), naming_scheme=hou.parmNamingScheme.Base1, disable_when=“”)
hou_node.addSpareParmTuple( myTemplate, in_folder“Convert”), create_missing_folders=True)

Attachments:
weirdness.jpg (20.4 KB)

--
Jobless
User Avatar
Member
678 posts
Joined: July 2005
Offline
Hey Macha,

Add , after “Convert” in this line hou_node.addSpareParmTuple( myTemplate, in_folder“Convert”), create_missing_folders=True) and it should work.

If you write it without comma python thinks that this is sequence of elements not one element in sequnce.
User Avatar
Member
1914 posts
Joined: Nov. 2006
Offline
Yeah, what Swann said. The in_folder argument expects a tuple of folder names to specify exactlly which folders/sub folders to insert the parameter in. For example, in_folder'Render', ‘Shading’) would put your parameter in the Render->Shading folder on an Geometry node.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
864 posts
Joined: Oct. 2008
Offline
When I create new nodes via Python, can I wire them up with each other? How?
--
Jobless
User Avatar
Member
1914 posts
Joined: Nov. 2006
Offline
Look at hou.Node.setFirstInput(), setNextInput(), setInput().
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
864 posts
Joined: Oct. 2008
Offline
Cool, that works.

and how about setting a nodes color? It isn't documented. I tried

col = hou.Color.rgb(0.6,0.1,0.1)

myobj.setColor( col )

and variations of this but it doesn't work.
--
Jobless
User Avatar
Member
1914 posts
Joined: Nov. 2006
Offline
hou.Color takes a tuple of rgb values for the constructor.
col = hou.Color((0.6, 0.1, 0.1))
mynode.setColor(col)

I highly recommend looking in the *toolutils.py modules in $HH/scripts/python to see good examples of a lot of common operations like these. A lot of the stuff has comments and it can be interesting to see what Houdini is doing under the hood.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
864 posts
Joined: Oct. 2008
Offline
New Question:

I have a bunch of copy-stamped objects.

Is it possible to access those objects through python and manipulate them (for example: scale the object that was copy-stamped at point 3)?
--
Jobless
  • Quick Links