logix1390 Posted September 22, 2018 Share Posted September 22, 2018 Hello, I have some python code that creates two different nodes in the `out` context. My question is. how can I create multiple nodes in one line instead of two. So far I have this: mantra=hou.node("/out").createNode("ifd"); hou.node("/out").createNode("geometry") Is there a way I can shorten this line of code so that I can store both nodes that are being created in one variable? My goal is to basically connect them as they are created. Any help would be greatly appreciated. thank you. Quote Link to comment Share on other sites More sharing options...
Atom Posted September 22, 2018 Share Posted September 22, 2018 (edited) I don't think so, because there are additional tasks you may want to do as well. Like set flags, overwrite default parameter values, connect inputs and position them in the network etc.. def returnValidHoudiniNodeName(passedItem): # Thanks to Graham on OdForce for this function! # Replace any illegal characters for node names here. return re.sub("[^0-9a-zA-Z\.]+", "_", passedItem) # Create the Material node. mat_name = returnValidHoudiniNodeName("mat_%s" % local_name_only) node_mat = node_geo.createNode("material", mat_name) if node_mat != None: node_mat.parm("shop_materialpath1").set("/shop/%s" % shader_name) node_mat.setInput(0,node_uv) node_mat.moveToGoodPosition() node_mat.setDisplayFlag(1) node_mat.setRenderFlag(1) Edited September 23, 2018 by Atom Quote Link to comment Share on other sites More sharing options...
logix1390 Posted September 24, 2018 Author Share Posted September 24, 2018 Hi Atom, Thank you for the response. I am not sure what is going on in the first half of the code. def returnValidHoudiniNodeName(passedItem): # Thanks to Graham on OdForce for this function! # Replace any illegal characters for node names here. return re.sub("[^0-9a-zA-Z\.]+", "_", passedItem) # Create the Material node. mat_name = returnValidHoudiniNodeName("mat_%s" % local_name_only) node_mat = node_geo.createNode("material", mat_name) if node_mat != None: node_mat.parm("shop_materialpath1").set("/shop/%s" % shader_name What exactly is going on here? Thank you again. 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.