Excellent. Thanks Ean. Works great.

Mark


Ean Carr wrote:
Hey Mark,

There are a few ways to do this. Here's the first way that comes to mind: just create a hidden text knob in your group called something like 'light_node_cache' with a value of 'my_light_node'. This will be your node name's cache; you'll need to set its value to the new node name each time the user changes it. Then you can do something like:

cached_n_name = n['light_node_cache'].value()
L = nuke.toNode(cached_n_name)
L.setName(new)
L_name = L.name() # get the node's name in case there were any collisions
n['light_node_cache'].setValue(L_name)
# If there were collisions...
if L_name != new:
    n['lightName'].setValue(L_name)

Again, not in front of nuke so I may have made typos, but that should get you going!

Cheers,
Ean

On Sat, Aug 11, 2012 at 8:37 AM, Mark Nettleton <[email protected] <mailto:[email protected]>> wrote:

    Thanks Ean!

    That works, once. The problem being that after 'my_light_node' has
    been renamed, the toNode('my_light_node') is no longer valid, and
    fails if you try to rename the node a second time.

    Mark



    Ean Carr wrote:
    ...or even better, use the setName method which I believe helps
    you avoid naming conflicts:

    nuke.toNode('my_light_node').setName(new)

    Hope all's well with you, btw!

    Ean

    On Sat, Aug 11, 2012 at 8:16 AM, Ean Carr <[email protected]
    <mailto:[email protected]>> wrote:

        Hey Mark,

        If the light node's named 'my_light_node', you would do
        something like:

        nuke.toNode('my_light_node')['name'].setValue(new)

        Not in front of Nuke at the moment, but that should work
        (once you change focus away from the lightName knob, probably).

        Cheers,
        Ean


        On Sat, Aug 11, 2012 at 7:25 AM, Mark Nettleton
        <[email protected] <mailto:[email protected]>> wrote:

            Hi,

            I have a Group which contains some Light nodes. The Group
            has a text entry knob.
            When the user enters text into that knob, I want the
            Light node inside the group to be renamed using the
            entered text.

            How do I do that?

            Thanks!


            set cut_paste_input [stack 0]
            version 6.3 v8
            push $cut_paste_input
            Group {
            name Group
            knobChanged "
            n = nuke.thisNode()
            k = nuke.thisKnob()
            if k.name <http://k.name>() == \"lightName\":
               if n\['lightName'].value() != \"\":
                   new = (n\['lightName'].getValue())
                   #insert clever bit of code here to change name of
            Light node inside Group.
                   n.setName(\"Group_Updated\")
            "
            selected true
            xpos 191
            ypos 76
            addUserKnob {20 User}
            addUserKnob {1 lightName l "Light name"}
            lightName "New light name"
            }
            Input {
             inputs 0
             name Input1
             xpos 210
             ypos 17
            }
            Light2 {
             name Light1
             xpos 220
             ypos 66
            }
            Output {
             name Output1
             xpos 210
             ypos 158
            }
            end_group

            _______________________________________________
            Nuke-users mailing list
            [email protected]
            <mailto:[email protected]>,
            http://forums.thefoundry.co.uk/
            http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users



    ------------------------------------------------------------------------
    _______________________________________________ Nuke-users
    mailing list [email protected]
    <mailto:[email protected]>,
    http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

    _______________________________________________
    Nuke-users mailing list
    [email protected]
    <mailto:[email protected]>,
    http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


------------------------------------------------------------------------

_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to