Juraj Posted November 1, 2016 Share Posted November 1, 2016 Hello, I want to convert node's name to uppercase with On Name Changed event. So I tried this code node = kwargs["node"] name = node.name() node.setName(name.upper(), True) But if I try to rename the node, I get error Unknown error when generating backtrace. And the name is converted to uppercase but from node abc becomes node ABC498 Not sure where this 498 number and error come from. I guess I am doing some beginner mistake. Thanks, Juraj Quote Link to comment Share on other sites More sharing options...
haggi Posted November 2, 2016 Share Posted November 2, 2016 Looks fine here. Did you check what's displayed if you print the content of "name"? Maybe there is a strange sign in there. Quote Link to comment Share on other sites More sharing options...
Juraj Posted November 2, 2016 Author Share Posted November 2, 2016 Hi, I checked content of "name", it seems fine. If I use node.setName(name.upper(), False) Then it works fine, but every time I change name, I get this error Traceback (most recent call last): File "opdef:/Sop/jt_OUT?OnNameChanged", line 3, in <module> File "/opt/hfs15.5.607/houdini/python2.7libs/hou.py", line 5458, in setName return _hou.Node_setName(*args, **kwargs) OperationFailed: The attempted operation failed. Any clues? I will test in another OS and machine. jt_OUT.hdanc Quote Link to comment Share on other sites More sharing options...
Juraj Posted November 3, 2016 Author Share Posted November 3, 2016 Tried it on another machine with Windows and I am getting the same error. It seems like really simple task, what am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Atom Posted November 3, 2016 Share Posted November 3, 2016 (edited) Maybe it is related to the fact that you are changing the name in the name change event? Consider my image. I have relplaced your name.upper() with a fixed uppercase string of "ABC". I have added prints. node = kwargs["node"] name = node.name() print node.name() node.setName("ABC", False) print node.name() So the first thing that happens is we print out the original name. "OUT_". Then we change the name to "ABC" successfully. Then we come back into the event (for some reason..?) and we print the name again, which is "ABC". Then we try to change the name to "ABC" but the name is already "ABC" so we get an error. If you think about it, your "OUT_" falls into the same boat. Because "OUT_" is already upper case you are essentially changing it to the same name. What if you wrote some code to detect if the new name is the same as the old name, and only assign the new name if it is different? This seems to work. Try setting your initial name to "out_" in the onCreate event and then you'll see it gets renamed to "OUT_" node = kwargs["node"] name = node.name() s = node.name().upper() if s != name: node.setName(s, True) print node.name() Edited November 3, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
Juraj Posted November 5, 2016 Author Share Posted November 5, 2016 Hi, thanks for explanation. It works well now. Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted November 5, 2016 Share Posted November 5, 2016 good old infinite recursive loop 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.