vrman Posted September 13, 2017 Share Posted September 13, 2017 i dont know why i cant rename my nodes with str variable , can anyone tell me what is the problem ? setName not working with getChildrenName variable , but you can change it with typing string directly , for example newNodeGroup.setName('Hello') here is the code myNodes = hou.selectedNodes() getChildren = myNodes.children()[0] getChildrenName = getChildren.name() newNodeGroup = myNodes.createNode('group') newNodeGroup.setName(getChildrenName) thanks Quote Link to comment Share on other sites More sharing options...
symek Posted September 13, 2017 Share Posted September 13, 2017 Not sure if this is related, but you have a bug in second line, since selectedNodes() returns a tuple, so you can't call children() on that. Also setName() can throw an exception if name isn't correct, like empty string, so most probably your getChildrenName has some issue. Quote Link to comment Share on other sites More sharing options...
vrman Posted September 13, 2017 Author Share Posted September 13, 2017 (edited) 24 minutes ago, symek said: Not sure if this is related, but you have a bug in second line, since selectedNodes() returns a tuple, so you can't call children() on that. Also setName() can throw an exception if name isn't correct, like empty string, so most probably your getChildrenName has some issue. yes you right , here is the corrected script , but still rename not working , and i dont know why : myNodes = hou.selectedNodes() getChildren = myNodes[0].children()[0] getChildrenName = getChildren.name() newNodeGroup = myNodes[0].createNode('group') newNodeGroup.setName(getChildrenName) the problem is in last line , if you change that to : newNodeGroup.setName(getChildrenName{0]) you can get characters by changing that number , but i cant get full name Edited September 13, 2017 by vrman Quote Link to comment Share on other sites More sharing options...
Atom Posted September 13, 2017 Share Posted September 13, 2017 It is not working because you are trying to rename your new node to the same exact name as an existing node. Try something like this... getChildrenName = "from_code" + getChildren.name() 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.