Jump to content


3 Float Vec with Python HDK


  • Please log in to reply
3 replies to this topic

#1 benne5

benne5

    Peon

  • Members
  • Pip
  • 5 posts
  • Joined: 10-February 10
  • Name:Matthew B

Posted 20 August 2012 - 09:44 PM

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.

Attached Files



#2 hopbin9

hopbin9

    Houdini Master

  • Members
  • PipPipPipPip
  • 803 posts
  • Joined: 14-March 10
  • Location:Canada
  • Name:Hop Bin

Posted 21 August 2012 - 06:24 AM

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.
Posted Image
Come download the free open source asset library for Houdini.
Help us reach 1,000 fans on facebook!

#3 Pazuzu

Pazuzu

    Initiate

  • Members
  • PipPip
  • 159 posts
  • Joined: 21-November 07
  • Location:Bogota - Colombia
  • Name:Alejandro Echeverry

Posted 21 August 2012 - 03:52 PM

Nice trick Thank You!!!

#4 benne5

benne5

    Peon

  • Members
  • Pip
  • 5 posts
  • Joined: 10-February 10
  • Name:Matthew B

Posted 21 August 2012 - 09:36 PM

Thanks Hop Bin!
I forgot about using asCode().  Great idea about writing to its own .txt file.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users