mavencolby Posted December 25, 2018 Share Posted December 25, 2018 Good morning and Merry Christmas! I need to evaluate a string path and get a parameter value from it. So far I have this as a string parm: `chsop("../cam")`/aperture/ This evaluates correctly as: /obj/rendercam/aperture/ However when I try to reference this as a ch() operation, it doesn't evaluate correctly. It reads 0. How can I drive a float parameter correctly? To be clear, I don't want to directly reference the camera: // NOT this ch("../../rendercam/aperture") I want the user to put the path of the camera in the otl and be able to derive the aperture from the string. Thanks! cw Quote Link to comment Share on other sites More sharing options...
mavencolby Posted December 25, 2018 Author Share Posted December 25, 2018 Okay so I've tried a little Python, this should work but I can't wrap my head around putting this into a parameter: def pig(): node = hou.node('/obj/Frustrum/') path = hou.evalParm(node.parm('cam').path()) x = hou.node(path) aperture = x.parm('aperture') n = hou.evalParm(aperture.path()) return n pig() I'm trying to set as "scalex" on a transform sop, and even when it's set to evaluate Python it returns 0. But the code works in the Python shell. What the heck is happening? Quote Link to comment Share on other sites More sharing options...
mavencolby Posted December 25, 2018 Author Share Posted December 25, 2018 Got it to work! It needed to "return pig()" at the end. The final Python code looked like this: def pig(): node = hou.node('/obj/Frustrum/') path = hou.evalParm(node.parm('cam').path()) x = hou.node(path) aperture = x.parm('aperture') n = hou.evalParm(aperture.path()) return n # NOTE the "return" before calling the procedure "pig()" return pig() This is probably overkill for what I was trying to do, but hey.. got my feet wet in Python! Hope this helps someone else. cw Quote Link to comment Share on other sites More sharing options...
anim Posted December 26, 2018 Share Posted December 26, 2018 (edited) you can just do this ch(chsop('cam') + '/aperture') get_parm_from_cam.hip Edited December 26, 2018 by anim Quote Link to comment Share on other sites More sharing options...
mavencolby Posted December 26, 2018 Author Share Posted December 26, 2018 6 hours ago, anim said: you can just do this ch(chsop('cam') + '/aperture') get_parm_from_cam.hip Ah great! Thanks Tomas! I was so close to that, and began pulling my hair out trying to figure which syntax was correct. Thanks for the solution cw 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.