benne5 Posted August 21, 2012 Share Posted August 21, 2012 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 Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted August 21, 2012 Share Posted August 21, 2012 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. Quote Link to comment Share on other sites More sharing options...
Pazuzu Posted August 21, 2012 Share Posted August 21, 2012 Nice trick Thank You!!! Quote Link to comment Share on other sites More sharing options...
benne5 Posted August 22, 2012 Author Share Posted August 22, 2012 Thanks Hop Bin! I forgot about using asCode(). Great idea about writing to its own .txt file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.