nukescripts.flags

Package nukescripts :: Module flags |
[hide private]
[frames] | no frames]

# Source Code for Module nukescripts.flags

     1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved.
     2
     3  import nuke
     4
     5 -def toggle(knob):
     6    """ "Inverts" some flags on the selected nodes.
     7
     8    What this really does is set all of them to the same value, by finding the
     9    majority value and using the inverse of that."""
    10
    11    value = 0
    12    n = nuke.selectedNodes()
    13    for i in n:
    14      try:
    15        val = i.knob(knob).value()
    16        if val:
    17          value += 1
    18        else:
    19          value -= 1
    20      except:
    21        pass
    22
    23    status = value < 0
    24    for i in n:
    25      if not nuke.exists(i.name()+"."+knob):
    26        continue
    27      knobbie = i.knob(knob)
    28      knobbie_str = i.name()+"."+knob
    29      size = nuke.animation(knobbie_str, "size")
    30      if size is not None and int(size) > 0:
    31        knobbie.setKeyAt(nuke.frame())
    32        knobbie.setValue(status)
    33      else:
    34        knobbie.setValue(status)
    35      nuke.modified(True)
    36