Jump to content
RogerW

HDA "on name changed"

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×