I'm confused, and surely can't see the .copy() function right in front of my nose…
I need to copy net1/A to net2/B - all I found was copyItems and the like, which allow you to copy groups of objects BUT keeping the same names until you eventually rename them later. I don't want to do that and rename afterward. I want to copy a node by giving it a new name to start with, because nodes with the same source name my already exist and shouldn't be overritten.
I can copy into a temp subnet, rename, then copy to the destination - but it seems to me there ought to be a simple mynet2node.copyItem('/obj/net1/A',name='newname')… could someone point it out for me?
Thanks!!
dani
best way to copy nodes to a new name with python?
8051 1 1- dani6
- Member
- 5 posts
- Joined: 6月 2017
- Offline
- friedasparagus
- Member
- 402 posts
- Joined: 6月 2014
- Offline
Hi Dani,
You don't have to worry about nodes being overwritten, as the normal resolution of conflicting node names takes place (if “null1” already exists, it gets renamed to “null2”).
The copyItems() function returns the newly created nodes in a tuple so you can rename them after copying. Something like:
Hope that helps
You don't have to worry about nodes being overwritten, as the normal resolution of conflicting node names takes place (if “null1” already exists, it gets renamed to “null2”).
The copyItems() function returns the newly created nodes in a tuple so you can rename them after copying. Something like:
net1 = hou.node("/obj/net1") net2 = hou.node("/obj/net2") nodestocopy = (net1.node("A"),) newcopies = net2.copyItems(nodestocopy) newcopies[0].setName("newname")
Hope that helps
Henry Dean
-
- Quick Links