Multi Line Python Expression

   6324   4   1
User Avatar
Member
53 posts
Joined: April 2012
Offline
Hello,

Yet again, I seem to get confused with what I can achieve using Python Expressions avoiding Python SOPs.

Let's say, I create a curve and place 6 points of the curve in the scene however I please… (Point's which's coordinates are visible in the coords section of the curve). I can see the XYZ position in the “Details View” too, which makes me think that there should be an easy way to access that information…

But my reduced knowledge of Houdini and Python isn't much help I admit.

If I create a sphere, which I want to be positioned at the 3rd point of the curve… I thought I would be able to put the coordinates of said point using a multi-line expression in the Translate values of the sphere (one for X, another for Y and a third one for Z).

But as soon as I type the following line in TranslateX of the sphere:

curve = hou.node(obj/curve_object1/curve1")

I'm stuck… I tried reading the Help files and anything I try doesn't seem to get me there…

Any clues on how to do it?


(I think I could easily get the information if I read the coordinates string, but I just started learning Houdini and I'm trying to understand it's limits and capabilities… So if there's a way to do this this way and I just don't know how to code it… It would be great to know how … And if there's an easier way… I'd love to know too Hahaha)

CHEERS!
User Avatar
Member
304 posts
Joined: May 2006
Offline
are you after the Python solution, or just the solution? because you certainly don´t need python for this.
You could simply copy the sphere over the third point of the curve, and there are a number of ways to do this. That´s why I´m asking which solution you´re after…
Javier Meroño
FX TD.
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Easier ways:

Copy SOP

Hscript expression (point(“your/node”, 3, P, 0) for x, point(“your/node”, 3, P, 1) for y, etc)

With python it *may* also be done in one liner, just more convoluted (untested code ahead!)


For x
hou.node(“your/node”).geometry().points().position()

For y and z change the last number to 1 and 2
-G
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Sorry! Forgot quotes around P on hscript expression! It should be “P”
-G
User Avatar
Member
512 posts
Joined: July 2009
Offline
here's how you can do it in the python shell, same also works as a multi-line expression of course:


>>> sphere = hou.node('/obj/sphere')
>>> curve = hou.node('/obj/curve_object1/curve1')
>>> p4 = curve.geometry().points()
>>> p4
<hou.Point #3 of geometry in /obj/curve_object1/curve1>
>>> pos = p4.position()
>>> tuple = sphere.parmTuple(“t”)
>>> tuple.set(pos)


cheers,

Manu
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
  • Quick Links