Jump to content

Using Python expression in the Channel CHOPs name paramater?


Recommended Posts

Hi

I cannot get to make this python expression work in the name field. Basically I need to create as many channels as there are nodes in the /obj path.

name : chan[0-`len(hou.node("/obj").glob("*"))`]

I have set the language to Python in the channel chops menu

thanks

Link to comment
Share on other sites

hi ,

i was trying few things and am posting here something that seems to work ( attached pic ).

created a integer parameter to put the python expression and referenced that from chan name parameter .

post-5487-130541249943_thumb.jpg

Link to comment
Share on other sites

hi ,

i was trying few things and am posting here something that seems to work ( attached pic ).

created a integer parameter to put the python expression and referenced that from chan name parameter .

Hey zarti, thanks that was very helpful. I am also wondering if there is a way to do this straight in the channel name box. Just curious about the right use of Python expressions in such cases.

thanks

Link to comment
Share on other sites

Isn't there a hou.Node.children() method which does the same thing as glob("*") ?

edward,

The glob("*") was just an example. The nice thing about glob is that I can get a list of certain items for example, like bones or cameras etc. I guess it should not be hard to parse a list from the "/obj" parent. I will try that one as well.

Link to comment
Share on other sites

since it's python this should work for you

"chan[1-%s]" %len(hou.node("/obj").glob("*"))

Btw your suggestion does not seem to work in the "channel" operators name field for some reason. I know this is a legitimate Python line.

Link to comment
Share on other sites

When using Python expressions in string parameters you generally need to set a key/expression on the parameter before you can enter the code.

1. Alt + LMB on the parameter to add a key.

2. LMB on the label to toggle to expression mode.

3. Edit the expression to clear out the default expression junk and put in whatever you want.

Sometimes it just works nicely if you toggle to expression mode at the very start and just type in things and it will set the expression for you.

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