Thread: Node settings Lock

Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 20 of 20
  1. #16  
    Join Date
    Oct 2008
    Posts
    334
    Quote Originally Posted by sathees View Post
    Hi metalcay This is really smart. But why dont you write If then else for this. If selected node is already locked then unlock it...... like this.

    I'm trying to creating Lock-Unlock python buttons. The problem is while run the lock function it also lock the Unlock button too. Trying to figure out solution for that.

    There's no ideal way to check whether the node is LOCKED or NOT. if the node is locked means => if all knobs are locked or if first knob is locked? it depends on RULES , what condition u want to make it to be "the node is locked". The script is unlimited , it's just u who need to create the proper 'rules' :-). For this simple toggle u don't need if/then/else , coz it can be solved with single NOT expression. This is the function if u want to check only the first knob is locked or not :

    Code:
    def locktoggle(nodes):
      for node in nodes :
        state=not node.allKnobs()[0].enabled()
        allknobs=node.allKnobs()
        for knob in allknobs:
           knob.setEnabled(state)
        nuke.toNode(node.name()).setSelected(False)
        nuke.toNode(node.name()).setSelected(True)
    
    
    nodes=nuke.selectedNodes()
    locktoggle(nodes)
    


    btw, u can create a right-click menu for every knob, but the problem is : after lock the knob, it become greyed out so there's no way u can do 'right-click' again.,.. this prevents u from unlocking the knob. This is not a bug, i prefer the term 'imperfection'. Also, when it's being greyed out, i can't cmd+drag the knob to create link. This is annoying.

    Cheers
    Reply With Quote  

  2. #17  
    Join Date
    Oct 2008
    Posts
    334
    Quote Originally Posted by sathees View Post
    Hi metalcay This is really smart. But why dont you write If then else for this. If selected node is already locked then unlock it...... like this.

    I'm trying to creating Lock-Unlock python buttons. The problem is while run the lock function it also lock the Unlock button too. Trying to figure out solution for that.

    Try this , i think it's better than if/then/else :-)

    Code:
    set cut_paste_input [stack 0]
    version 6.3 v4
    push $cut_paste_input
    Transform {
     center {960 540}
     name Transform6
     label "\[python -exec \{\nthis=nuke.thisNode()\nx=not this.knob('lockz').value()\nallknobs=this.allKnobs()\nfor knob in allknobs:\n   if knob.name() != 'lockz':\n      knob.setEnabled(x) \n\} \n]"
     selected true
     xpos -377
     ypos -113
     addUserKnob {20 User}
     addUserKnob {6 lockz l "lock me please" +STARTLINE}
    }
    in the user tab, there's lock control.

    Cheers
    Reply With Quote  

  3. #18  
    Join Date
    Aug 2006
    Location
    India
    Posts
    246
    Here is the simple solution for lock and unlock node settings. I made some changes on 'metalcays' code and assigned shortcut keys. temp solution for lock the node settings.

    for lock - ctrl+l
    for unlock - shift+l

    enjoy....
    Attached Files
    Failure is not an option.. But failure has to be an option...
    ____________________
    My Nuke Tutorial page
    Reply With Quote  

  4. #19  
    Join Date
    Oct 2008
    Posts
    334
    actually you can just create single function then pass the 'state' argument contain value of True or False. so delete the unlockNode.py and modify lockNode.py :edit the 'def lockNode()' part as follow :

    Code:
    import nuke
    def lockknob(nodes,state):
      for node in nodes :    
          allknobs=node.allKnobs()
          for knob in allknobs: 
              knob.setEnabled(state)
          nuke.toNode(node.name()).setSelected(False)
          nuke.toNode(node.name()).setSelected(True)e)
    
    def lockNode(state):
      a=nuke.selectedNodes()
      lockknob(a,not state)
    


    then for menu:
    Code:
    import lockNode
    menuBar.addCommand('Edit/Node/lockNode', 'lockNode.lockNode(True)', 'ctrl+l')
    menuBar.addCommand('Edit/Node/unlockNode', 'lockNode.lockNode(False)', 'shift+l')


    i use 'not state' insted of 'state' . U can use 'state' also if u want and inverse the logic. But i'm doing this way to make the function() readable , means :
    --> lockNode(TRUE) is like saying : yes, TRUE.. i want to Lock the Node.
    --> lockNode(FALSE) is like saying : no/FALSE... do not lock the Node.

    cheers
    Reply With Quote  

  5. #20  
    Join Date
    Aug 2006
    Location
    India
    Posts
    246
    Ha how i forgot this ........ Nice work metalcay..
    Failure is not an option.. But failure has to be an option...
    ____________________
    My Nuke Tutorial page
    Reply With Quote  

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Nuke 5.1 v1 Released
    By shot_grable in forum NUKE from The Foundry
    Replies: 36
    Last Post: July 17th, 2010, 01:33 AM
  2. paint node (clone mode) follow tracker node
    By vincepapaix in forum NUKE from The Foundry
    Replies: 10
    Last Post: March 26th, 2010, 07:38 PM
  3. associated command to node in properties (buttons command)
    By pjb in forum NUKE from The Foundry
    Replies: 1
    Last Post: July 31st, 2009, 06:42 PM
  4. How do you lock a node in Nuke?
    By hiphopcr in forum NUKE from The Foundry
    Replies: 3
    Last Post: April 22nd, 2009, 12:37 PM
  5. Unable to render after a Card3D node
    By blackened in forum NUKE from The Foundry
    Replies: 12
    Last Post: February 10th, 2009, 03:26 AM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts