HappehLemons Posted January 2, 2019 Share Posted January 2, 2019 (edited) New to Python scripting. Hoping to get a better understand of how to use the documentation and features to create shaders in my currently viewing spot in the Network editor. What I want to do should be simple enough. I want to create a shelf tool to automatically makes a shader network in the current node network I am viewing. However, I am a little confused on how to generate a shader using python in a variable location. Here's why I've gotten done so far: myNode = hou.node('/mat') myNode.createNode('principledshader') This works! However, I would like this to place shaders in my current shader network I'm viewing without having to hardcode it (As it works now it just put them in /mat). How can I do something like this? Hope this makes sense! Edited January 2, 2019 by HappehLemons Quote Link to comment Share on other sites More sharing options...
anim Posted January 2, 2019 Share Posted January 2, 2019 you can do something like this, currently it will create your vop nodes in the first found network editor of the Vop type, so even attrib vops or so, you may need to do some more filtering if you want specifically Matnets, but this should get you going tabs = hou.ui.currentPaneTabs() # get all active tabs tabs = [tab for tab in tabs if tab.type() == hou.paneTabType.NetworkEditor] # keep only network editors tabs = [tab for tab in tabs if tab.pwd().childTypeCategory().name() == "Vop"] # keep only Vopnets if tabs: node = tabs[0].pwd() ps = node.createNode('principledshader') Quote Link to comment Share on other sites More sharing options...
HappehLemons Posted January 2, 2019 Author Share Posted January 2, 2019 (edited) This works perfect, thanks for the guidance. Edited January 2, 2019 by HappehLemons 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.