Jump to content

setExpression python problem


Xims

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()

Link to comment
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)

Link to comment
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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...