Jump to content

[SOLVED]Assign Expression To A Numeric Parm?


Atom

Recommended Posts

Hi All,

I am trying to assign an expression to a parameter using python. I want to link two objects together.

I get a type error "Cannot set a numeric parm to a non-numeric value."

I understand I am trying to assign a string to a number field, but the string contains the expression.

Is this possible in using the current python in Houdini 15.5?

Here is my code so far...

trc_source = "/obj/trc"
trc_target = "/obj/angela_1_T_pose_fbx"
lst_source_blocks = ["Root"]
lst_target_blocks = ["hip_To_abdomen"]

for (i,name) in enumerate(lst_source_blocks):
    source_candidate = "%s/%s" % (trc_source, name)
    n = hou.node(source_candidate)
    if n != None:
        target_candidate = "%s/%s" % (trc_target, lst_target_blocks[i])
        m = hou.node(target_candidate)
        if m != None:
            s = '`ch("%s/%s/tx")`' % (trc_source,name)
            m.parm("tx").set(s)
	
Edited by Atom
Link to comment
Share on other sites

You can use hou.Parm.setExpression() http://www.sidefx.com/docs/houdini15.5/hom/hou/Parm#setExpression to set an expression.

Alternatively you can actually set parms to other parms and it will automatically create channel references for you:

tx = hou.parm("/obj/geo1/tx")
ty = hou.parm("/obj/geo1/ty")
ty.set(tx)

 

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...