kursad Posted May 14, 2011 Share Posted May 14, 2011 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 Quote Link to comment Share on other sites More sharing options...
zarti Posted May 14, 2011 Share Posted May 14, 2011 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 . Quote Link to comment Share on other sites More sharing options...
kursad Posted May 14, 2011 Author Share Posted May 14, 2011 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 Quote Link to comment Share on other sites More sharing options...
anim Posted May 15, 2011 Share Posted May 15, 2011 since it's python this should work for you "chan[1-%s]" %len(hou.node("/obj").glob("*")) Quote Link to comment Share on other sites More sharing options...
kursad Posted May 15, 2011 Author Share Posted May 15, 2011 anim, thanks for the cool solution . I have made a mistake of trying to mix Python and Hscript as well. Quote Link to comment Share on other sites More sharing options...
edward Posted May 16, 2011 Share Posted May 16, 2011 Isn't there a hou.Node.children() method which does the same thing as glob("*") ? Quote Link to comment Share on other sites More sharing options...
kursad Posted May 16, 2011 Author Share Posted May 16, 2011 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. Quote Link to comment Share on other sites More sharing options...
edward Posted May 16, 2011 Share Posted May 16, 2011 Ah ok, I just thought it was weird with your use of glob("*") Quote Link to comment Share on other sites More sharing options...
kursad Posted May 17, 2011 Author Share Posted May 17, 2011 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. Quote Link to comment Share on other sites More sharing options...
graham Posted May 17, 2011 Share Posted May 17, 2011 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. Quote Link to comment Share on other sites More sharing options...
kursad Posted May 17, 2011 Author Share Posted May 17, 2011 graham, thanks for the tip. Is that a bug or the way it was designed? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.