JJ FX Posted February 22, 2018 Share Posted February 22, 2018 (edited) Hi Can I somehow call the the node itself? Example: A node calls itself in the creation to rename itself from "my_node" to "more_owesome_node" Edited February 22, 2018 by JJ FX Quote Link to comment Share on other sites More sharing options...
ikoon Posted February 22, 2018 Share Posted February 22, 2018 Hi JJ, important is the variable on the left side, when creating: node_mrg = hou.node(container).createNode('object_merge',name_mrg) You can then refer to this node like this: node_mrg.setName("newname") Here is whole example: # define offsetx = 3 offsety = 0 color = hou.Color(0.0, 0.0, 0.0) node_src = hou.selectedNodes()[0] name_src = node_src.name() posx = node_src.position()[0] + offsetx posy = node_src.position()[1] + offsety #create, name, pos container = node_src.parent().path() name_mrg = "IN_" + name_src node_mrg = hou.node(container).createNode('object_merge',name_mrg) node_mrg.setPosition( [posx,posy] ) #parm path_src = node_src.path() parm = node_mrg.parm("objpath1") parm.set(path_src) #setcol node_src.setColor(color) node_mrg.setColor(color) 1 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 22, 2018 Share Posted February 22, 2018 In the Operator Type Properties → Scripts tab select "On Created" event handler, change "Edit as" to Python. Here is basic code: node = kwargs['node'] node.setName('some_special_name') For default operators you need to make a shelf tool and create node and change it's name manually in the tool script. Custom assets also use tool script. In Operator Type Properties → Tools tab and the tool script looking like this: import soptoolutils soptoolutils.genericTool(kwargs, '$HDA_NAME') The function call at the last line returns fully created node instance. After On Created event was executed. You can use it too: import soptoolutils node = soptoolutils.genericTool(kwargs, '$HDA_NAME') node.setName('some_special_name') It's more logical to use On Created, but sometimes it doesn't work. For example, if I remember correctly, you can't set node position in it, it will be overridden. 1 1 Quote Link to comment Share on other sites More sharing options...
JJ FX Posted February 22, 2018 Author Share Posted February 22, 2018 wow, big thanks guys 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.