コード例 #1
0
    def reinitialise(self):
        #reset all the panels to default state when reopened
        self.node = None
        self.layerCopyValue = 'none'
        self.copyFrom0Value = 'none'
        self.copyTo0Value = 'none'
        self.copyFrom1Value = 'none'
        self.copyTo1Value = 'none'
        self.copyFrom2Value = 'none'
        self.copyTo2Value = 'none'
        self.copyFrom3Value = 'none'
        self.copyTo3Value = 'none'

        try:
            with self.context:
                if not len(nuke.selectedNodes()) > 1:
                    if nuke.selectedNode().Class() == 'Copy':
                        self.node = nuke.selectedNode()
                        self.layerCopyValue = self.node.knobs(
                        )['channels'].value()
                        self.copyFrom0Value = self.node.knobs()['from0'].value(
                        )
                        self.copyTo0Value = self.node.knobs()['to0'].value()
                        self.copyFrom1Value = self.node.knobs()['from1'].value(
                        )
                        self.copyTo1Value = self.node.knobs()['to1'].value()
                        self.copyFrom2Value = self.node.knobs()['from2'].value(
                        )
                        self.copyTo2Value = self.node.knobs()['to2'].value()
                        self.copyFrom3Value = self.node.knobs()['from3'].value(
                        )
                        self.copyTo3Value = self.node.knobs()['to3'].value()
        except:
            pass
        self.layerCopy.lineEdit.setText(self.layerCopyValue)
        self.layerCopy.lineEdit.updateList(nuke.layers() + ['none', 'all'])
        extras = ['none', 'red', 'green', 'blue', 'alpha']
        self.channelCopy0.update(self.copyFrom0Value, self.copyTo0Value,
                                 nuke.channels() + extras)
        self.channelCopy1.update(self.copyFrom1Value, self.copyTo1Value,
                                 nuke.channels() + extras)
        self.channelCopy2.update(self.copyFrom2Value, self.copyTo2Value,
                                 nuke.channels() + extras)
        self.channelCopy3.update(self.copyFrom3Value, self.copyTo3Value,
                                 nuke.channels() + extras)

        self.layerCopy.lineEdit.setFocus()
        self.layerCopy.lineEdit.selectAll()

        self.modifyNodeCheckBox.setChecked(True)
        self.modifyNodeCheckBox.setVisible(True)
        self.updateSubtitle()
コード例 #2
0
 def test_add_layer(self):
     from edit import add_layer
     self.assertNotIn('test', nuke.layers())
     add_layer('test')
     self.assertIn('test', nuke.layers())
     for i in ('test.red', 'test.green', 'test.blue', 'test.alpha'):
         self.assertIn(i, nuke.channels())
コード例 #3
0
ファイル: branchout.py プロジェクト: RonThomas/nuke.env
def branchout():
    
    sn = nuke.selectedNode()
    ch = nuke.channels(sn)
    xp = sn['xpos'].value()
    yp = sn['ypos'].value()

    layers = []
    valid_channels = ['red', 'green', 'blue', 'alpha', 'black', 'white']

    for each in ch:
        layer_name = each.split('.')[0]
        tmp = []
        for channel in ch:
            if channel.startswith(layer_name) == True:
                tmp.append(channel)
        if len(tmp) < 4:
            for i in range(4-len(tmp)):
                tmp.append(layer_name+".white")
        if tmp not in layers:
            layers.append(tmp)
            
    for each in layers:
        layer = each[0].split('.')[0]
        ch1 = each[0].split('.')[1]
        ch2 = each[1].split('.')[1]
        ch3 = each[2].split('.')[1]
        ch4 = each[3].split('.')[1]
        
        if ch1 not in valid_channels:
            ch1 = "red red"
        else:
            ch1 = ch1+" "+ch1
            
        if ch2 not in valid_channels:
            ch2 = "green green"
        else:
            ch2 = ch2+" "+ch2
            
        if ch3 not in valid_channels:
            ch3 = "blue blue"
        else:
            ch3 = ch3+" "+ch3
            
        if ch4 not in valid_channels:
            ch4 = "alpha alpha"
        else:
            ch4 = ch4+" "+ch4
            
        prefs = "in " + layer + " " + ch1 + " " + ch2 + " " + ch3 + " " + ch4
        shuffle = nuke.createNode('Shuffle', prefs)
        shuffle.knob('label').setValue(layer)
        shuffle.setInput(0, sn)
        
        
        
コード例 #4
0
ファイル: shuffleLayers.py プロジェクト: robmoggach/nuke-py
def shuffleLayers(nodes):
  '''
  Shuffles a multi-layer EXR to multiple shuffle nodes
  '''
  for node in nodes:
    channels = nuke.channels(node)
    posX = node['xpos'].value()
    posY = node['ypos'].value()
    layers = []
    validChannels = ['red', 'green', 'blue', 'alpha', 'black', 'white']

    for each in channels:
      layerName = each.split('.')[0]
      tmp = []
      for channel in channels:
        if channel.startswith(layerName) == True:
          tmp.append(channel)
      if len(tmp) < 4:
        for i in range(4-len(tmp)):
          tmp.append("%s.white" % layerName)
      if tmp not in layers:
        layers.append(tmp)

    for each in layers:
      layer = each[0].split('.')[0]
      channel1 = each[0].split('.')[1]
      channel2 = each[1].split('.')[1]
      channel3 = each[2].split('.')[1]
      channel4 = each[3].split('.')[1]

      if channel1 not in validChannels:
        channel1 = "red red"
      else:
        channel1 = "%s %s" % (channel1, channel1)

      if channel2 not in validChannels:
        channel2 = "green green"
      else:
        channel2 = "%s %s" % (channel2, channel2)

      if channel3 not in validChannels:
        channel3 = "blue blue"
      else:
        channel3 = "%s %s" % (channel3, channel3)

      if channel4 not in validChannels:
        channel4 = "alpha alpha"
      else:
        channel4 = "%s %s" % (channel4, channel4)

      prefs = "in %s %s %s %s %s" % (layer, channel1, channel2, channel3, channel4)
      shuffle = nuke.createNode('Shuffle', prefs)
      shuffle.knob('label').setValue('[value in]')
      shuffle.setInput(0, node)
コード例 #5
0
ファイル: branchout.py プロジェクト: mitrakhov/pipeline
def branchout():

    sn = nuke.selectedNode()
    ch = nuke.channels(sn)
    layers = []
    valid_channels = ["red", "green", "blue", "alpha", "black", "white"]

    for each in ch:
        current = each.split(".")
        layer = current[0]
        channel = current[1]
        tmp = []

        for x in ch:
            if x.startswith(layer) == True:
                tmp.append(x)

        if len(tmp) < 4:
            for i in range(4 - len(tmp)):
                tmp.append(layer + ".black")

        if tmp not in layers:
            layers.append(tmp)

    for each in layers:
        name = each[0].split(".")[0]

        r = each[0].split(".")[1]
        if r not in valid_channels:
            r = valid_channels[0]

        g = each[1].split(".")[1]
        if g not in valid_channels:
            g = valid_channels[1]

        b = each[2].split(".")[1]
        if b not in valid_channels:
            b = valid_channels[2]

        a = each[3].split(".")[1]
        if a not in valid_channels:
            r = valid_channels[3]

        inLayer = "in " + name + " red " + r + " green " + g + " blue " + b + " alpha " + a
        shuffle = nuke.createNode("Shuffle", inLayer)
        shuffle.knob("label").setValue(name)
        shuffle.setInput(0, sn)
コード例 #6
0
def branchout():

    sn = nuke.selectedNode()
    ch = nuke.channels(sn)
    layers = []
    valid_channels = ['red', 'green', 'blue', 'alpha', 'black', 'white']

    for each in ch:
        current = each.split('.')
        layer = current[0]
        channel = current[1]
        tmp = []

        for x in ch:
            if x.startswith(layer) == True:
                tmp.append(x)

        if len(tmp) < 4:
            for i in range(4 - len(tmp)):
                tmp.append(layer + ".black")

        if tmp not in layers:
            layers.append(tmp)

    for each in layers:
        name = each[0].split('.')[0]

        r = each[0].split('.')[1]
        if r not in valid_channels:
            r = valid_channels[0]

        g = each[1].split('.')[1]
        if g not in valid_channels:
            g = valid_channels[1]

        b = each[2].split('.')[1]
        if b not in valid_channels:
            b = valid_channels[2]

        a = each[3].split('.')[1]
        if a not in valid_channels:
            r = valid_channels[3]

        inLayer = "in " + name + " red " + r + " green " + g + " blue " + b + " alpha " + a
        shuffle = nuke.createNode('Shuffle', inLayer)
        shuffle.knob('label').setValue(name)
        shuffle.setInput(0, sn)
コード例 #7
0
def shuffleToLayers(nodes, margins=[50,30], dots=True):
  '''
  Shuffles a multi-layer EXR to multiple shuffle nodes
  '''
  node_xywh=[]
  dot_xywh=[]
  shuf_xywh=[]
  for node in nodes:
    channels = nuke.channels(node)
    if not node_xywh:
      node_xywh = [node.xpos(),node.ypos(), node.screenWidth(), node.screenHeight()]
    else:
      node.setXYpos(shuf_xywh[0] + (shuf_xywh[2] + dot_xywh[2])/2 + margins[0], dot_xywh[1] - margins[1] - node_xywh[3])
    layers = []
    validChannels = ['red', 'green', 'blue', 'alpha', 'black', 'white']
    dot_xywh = []

    for each in channels:
      layerName = each.split('.')[0]
      tmp = []
      for channel in channels:
        if channel.startswith(layerName):
          tmp.append(channel)
      if len(tmp) < 4:
        for i in range(4-len(tmp)):
          tmp.append("%s.white" % layerName)
      if tmp not in layers:
        layers.append(tmp)

    for each in layers:
      layer = each[0].split('.')[0]
      channel1 = each[0].split('.')[1]
      channel2 = each[1].split('.')[1]
      channel3 = each[2].split('.')[1]
      channel4 = each[3].split('.')[1]

      if channel1 not in validChannels:
        channel1 = "red red"
      else:
        channel1 = "%s %s" % (channel1, channel1)

      if channel2 not in validChannels:
        channel2 = "green green"
      else:
        channel2 = "%s %s" % (channel2, channel2)

      if channel3 not in validChannels:
        channel3 = "blue blue"
      else:
        channel3 = "%s %s" % (channel3, channel3)

      if channel4 not in validChannels:
        channel4 = "alpha alpha"
      else:
        channel4 = "%s %s" % (channel4, channel4)

      prefs = "in %s %s %s %s %s" % (layer, channel1, channel2, channel3, channel4)

      dot = nuke.nodes.Dot()
      shuffle = nuke.createNode('Shuffle', prefs)
      shuffle.knob('label').setValue('[value in]')
      shuffle.setInput(0, dot)

      if not dot_xywh:
        dot.setInput(0, node)
        dot_xywh = [dot.xpos(), dot.ypos(), dot.screenWidth(), dot.screenHeight()]
        if not shuf_xywh:
          dot.setXYpos( node_xywh[0] + (node_xywh[2]-dot_xywh[2])/2, node_xywh[1] + node_xywh[3] + margins[1])
        else:
          dot.setXYpos( shuf_xywh[0] + margins[0] + shuf_xywh[2], shuf_xywh[1] - margins[1] - dot_xywh[3])
      else:
        dot.setInput(0, nuke.toNode(dotName))
        dot.setXYpos(dot_xywh[0] + shuffle.screenWidth() + margins[0], dot_xywh[1])        

      dotName = dot.name()
      dot_xywh = [dot.xpos(), dot.ypos(), dot.screenWidth(), dot.screenHeight()]
      shuffle.setXYpos(dot_xywh[0]-(shuffle.screenWidth()-dot_xywh[2])/2, dot_xywh[1] + dot_xywh[3] + margins[1])
      shuf_xywh = [shuffle.xpos(), shuffle.ypos(), shuffle.screenWidth(), shuffle.screenHeight()]