multi-line python expression

   4395   3   1
User Avatar
Member
50 posts
Joined: July 2005
Offline
I'm trying to create a multi-line python expression that will automatically place the bottom of an object (lets say a tube) at the zx plane. I know that it should be pretty simple (ie. ty = height/2) but when I try to put a multi-line python expression into the ty parameter of the tube I get an error. here is the expression (I'm sure that it is not as simplified as it should be):

“n = hou.node('obj/geo1/tube1')
h = n.parm('height')
h = h/2
return h”


and here is the error that I am getting:

Error evaluating autocompletion:
“ File \”<stdin>\“, line 1
__import__('houdiniInterpreter').getCallTipOrAutoCompleteArgumentsList(\”n = hou.node('obj/geo1/tube1')
^
SyntaxError: EOL while scanning single-quoted string
"

I also thought that this should be pretty simple to create a shelf tool called lets say ‘place’ that prompted for the value to be set (in the example above this would be the ‘tx’value) and the value to use as a reference ('height').

I'm thinking that this would be useful if I had a bunch of items on a table and I wanted to change the height of the table the items would still be sitting on the top of the table instead of hanging in space etc.

Any thoughts?
~the most important things in life aren't things~
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
A couple of things I see wrong:

1. First of all you don't need to wrap your expression in quotes. That is what is causing your error.

2. When you assign ‘n’ you are missing a “/” in front of the path to /obj.

3. When you assign ‘h’ you are assigning to it a reference to a hou.Parm object, not a value. You need to do something like:
h = n.parm(“height”).eval()
or
h = n.evalParm(“height”)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
50 posts
Joined: July 2005
Offline
The quotes were just for posting - I didn't actually have them in the expression. But I was definitely missing the slash etc.

Thanks a bunch!

What about creating a tool for this? How would I prompt for values?
~the most important things in life aren't things~
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
If you want to prompt for values you could take a look at hou.ui.readInput() or hou.ui.readMultiInput().

If I was going to create such a tool I'd consider an automated approach in which I'd select an object to place, then select an object to place it on. Houdini would easily figure out how to transform the object to place to the correct height and position. It could be taken a step further to allow you to select an actual piece of geometry and use information from that to set up correct orientations and whatnot.
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links