Jump to content

HDA "on name changed"


RogerW

Recommended Posts

Hi all,

I am having some trouble with the "on name change" event handler on an HDA. 

I want to be able to name nodes inside of my hda based off of a new name that I give the HDA after I have dropped it in my scene.

The code works as a button but not when triggered on the change name event. I even tried hou.Parm.pressButton() in the on name changed even script but no dice...

here is a sample :

Quote

def updatename():
    
    hdaname = hou.node(".").name()
    mynode = hou.node(".").children()[0]
    mynode.setName(hdaname)
    print ("the nodes name has been changed to {}".format(hdaname))
 

attached a example otl as well...

Is there any other way that I can do this..

Many Thanks

change_my_name.hda

Link to comment
Share on other sites

Hello,

This should work fine in the on name change event, without the button press

node = kwargs["node"]
hdaname = node.name()
for child in node.children():
    child.setName(hdaname)
    print ("the child node name has been changed to {}".format(hdaname))  

As a warning though this style of renaming nodes will generally cause more issues than you are trying to solve. 

-Ben

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...