Jump to content

cant rename node with variable


vrman

Recommended Posts

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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 by vrman
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...