Jump to content

3 Float Vec with Python HDK


benne5

Recommended Posts

Hi all,

I have written a measure shelf tool. When executed a ui pops up asking for a geo and its transforms. It then repeats this process for a second geo. A line is then created between the centroids of these two geos. At the same time a node is created which displays the distance between the two points.

Understandably, this would be much faster to create node by node within Houdini rather than scripting. However, my purpose in doing this was to dive deeper into the HDK.

I want to edit the parameter interface of the of the object containing my two geos by promoting their transforms to a folder(tab) at object level. How do I programmatically create a 3 float vector on object level upon execution of my shelf button? I suspect that hou.FloatParmTemplate is involved in this, but I can't seem to work it into my code correctly. Please see my attached script.

Any help would be much appreciated.

measure_tool_python.txt

Link to comment
Share on other sites

Hi,

You can create a vector 3 parameter using the hou.FloatParmTemplate and passing 3 as the third parameter.

Also, here's a nice little trick. You could create the node you would like manually in Houdini, and then in the Python shell use the asCode() method to convert it to Python.

For example; Create a null object and add your custom parameters that you need, and then type this in the Python shell.

n = hou.node("/obj/null1")
f = open("c:/houdini.txt","w")
f.write(n.asCode())
f.close()

That will dump the Python code to recreate the /obj/null1 object to a text file. You can then inspect the file to see how things are created.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...