Jump to content
Sign in to follow this  
Xims

setExpression python problem

Recommended Posts

Hi, I'm a total noob at python and I need a little help

I'm trying to set an expression on a channel in a node, but the problem is that I need to get this result: point("../Rot", 0, "t", 0) Where the(Rot) can change depending on the Node that is created.

so if it creates a Rot1 I need it to set the expression to: point("../Rot1", 0, "t", 0)

Can anyone help ?

Below is just an example not a working version

hou = hou.node("obj")

Rot = hou.createNode("geo",node_name = "Rot")

transform2 = hou.node("obj/DormerMesh/xform3")

transform2.parm("tx").setExpression()

Share this post


Link to post
Share on other sites

Something like this should work. I also modified it slightly to point to the display node of your target node, since in this case you can't access information from an Object with a point expression.

node = hou.node("/obj").createNode("geo", "Rot")
xform = hou.node("/obj/DormerMesh/xform3")

expr = 'point("{0}", 0, "t", 0)'.format(xform.relativePathTo(node.displayNode()))

xform.parm("tx").set(expr)

Share this post


Link to post
Share on other sites

Something like this should work. I also modified it slightly to point to the display node of your target node, since in this case you can't access information from an Object with a point expression.

node = hou.node("/obj").createNode("geo", "Rot")
xform = hou.node("/obj/DormerMesh/xform3")

expr = 'point("{0}", 0, "t", 0)'.format(xform.relativePathTo(node.displayNode()))

xform.parm("tx").set(expr)

thanks this works perfect

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×