Jump to content

Is it possible to assign a parameter to another in Python at once?


Recommended Posts

Hi,

I have a matrix4 parameter with 16 float fields. I can assign references to them one by one, but is it possible to do it at once. So like:


matrixParm.set(anotherMatrixParm)

[/CODE]

instead of:

[CODE]
m1.set(mm1)
m2.set(mm2)
m3.set(mm3)
[/CODE]

etc

When I do this, it can't find my matrix parameter called "m" in the attribcreate1.

[CODE]hou.node('/obj/geo1/attribcreate1').parm('m')[/CODE]

It works if I use "m1", "m2" for individual fields, but I want to assign the whole parameter like above.

Is this possible?

Thanks :)

Link to comment
Share on other sites

A parameters as a whole is generally referred to as a parameter tuple. This is basically a collection of the sub parms. Take the Translate parm on an object for example.

>>> pt=hou.parmTuple('/obj/geo1/t')
>>> for parm in pt:
...	 parm
...
<hou.Parm tx in /obj/geo1>
<hou.Parm ty in /obj/geo1>
<hou.Parm tz in /obj/geo1>

This is the reason you cannot find just 'm'. hou.Node.parmTuple('m') should return the parm tuple named after 'm': m1, m2, ....

That being said, hou.Parm objects support setting to other hou.Parm objects (hou.Parm.set(hou.Parm)) and automatically generating the corresponding channel references. Unfortunately hou.ParmTuples don't (existing RFE).

Luckily hou.ParmTuple objects are iterable with the hou.Parm objects contained in them. You can do something like this:

def setParmTupleToParmTuple(m, mm):
    for m_parm, mm_parm in zip(m, mm):
  	  m_parm.set(mm_parm)

  • Like 1
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...