LaidlawFX Posted November 15, 2016 Share Posted November 15, 2016 (edited) I'm trying to build a list of all the parameters of a certain type from a node in python. For instance for a geo node, I want to build a list of all the toggle parameters on it. Comparing hou.node('/obj/geo1').asCode() and hou.node('/obj/geo1').parms() was going down a very messy road. I was hoping there was a way to use just the .parms() and check if each parameter is a toggle type? *Edit I feel like this may have something to do with it, https://www.sidefx.com/docs/houdini15.5/hom/hou/ToggleParmTemplate However only when I add a spare parameter and run .asCode() does it seem to reference this, and I can compare against .parms(), but it doesn't work on regular parameters. Edited November 15, 2016 by LaidlawFX Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 15, 2016 Share Posted November 15, 2016 toggles = [p for p in node.parms() if p.parmTemplate().type() == hou.parmTemplateType.Toggle] toggles = [p for p in node.parms() if isinstance(p.parmTemplate(), hou.ToggleParmTemplate)] Not sure which is better. 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted November 15, 2016 Share Posted November 15, 2016 (edited) Wow F1, only 8 minutes apart. You can fetch the parm type using code like this. p = node.parm("parm_test") pt = p.parmTemplate() print pt.type() Or maybe even more scanning of the node like this. node = hou.pwd() node_path_to_self = "/obj/pythonscript1" # Add code to modify contained geometries. # Use drop down menu to select examples. lst_types = [] lst_toggles = [] lst_floats = [] def returnParmType(passedParm): t = passedParm.parmTemplate().type() return str(t) def addToToggles(node_path,parm_name): lst_toggles.append((node_path, parm_name)) def addToFloats(node_path, parm_name): lst_floats.append((node_path, parm_name)) for p in node.parms(): s = returnParmType(p) # Also support String, Int, Menu if s.find("Float") != -1: addToFloats(node_path_to_self, p.name()) if s.find("Toggle") != -1: addToToggles(node_path_to_self, p.name()) Edited November 15, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) 18 minutes ago, f1480187 said: toggles = [p for p in node.parms() if p.parmTemplate().type() == hou.parmTemplateType.Toggle] toggles = [p for p in node.parms() if isinstance(p.parmTemplate(), hou.ToggleParmTemplate)] Not sure which is better. Your my hero... and don't ever change. Thanks so much. *Edit: Atom you can belong in my extended hero universe Edited November 15, 2016 by LaidlawFX Atom Quote Link to comment Share on other sites More sharing options...
papsphilip Posted September 20, 2021 Share Posted September 20, 2021 On 11/15/2016 at 4:29 AM, Atom said: Wow F1, only 8 minutes apart. You can fetch the parm type using code like this. p = node.parm("parm_test") pt = p.parmTemplate() print pt.type() Or maybe even more scanning of the node like this. node = hou.pwd() node_path_to_self = "/obj/pythonscript1" # Add code to modify contained geometries. # Use drop down menu to select examples. lst_types = [] lst_toggles = [] lst_floats = [] def returnParmType(passedParm): t = passedParm.parmTemplate().type() return str(t) def addToToggles(node_path,parm_name): lst_toggles.append((node_path, parm_name)) def addToFloats(node_path, parm_name): lst_floats.append((node_path, parm_name)) for p in node.parms(): s = returnParmType(p) # Also support String, Int, Menu if s.find("Float") != -1: addToFloats(node_path_to_self, p.name()) if s.find("Toggle") != -1: addToToggles(node_path_to_self, p.name()) Just what i was looking for! How can you remove parameters?? 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.