Преглед изворни кода

2021-07-12

sceneControl: added 'removeKellerTab' function.
Martin Sächsinger пре 3 година
родитељ
комит
05f7eceaf9
1 измењених фајлова са 136 додато и 118 уклоњено
  1. 136
    118
      pythonpluginsUI/sceneControl/sceneControl.py

+ 136
- 118
pythonpluginsUI/sceneControl/sceneControl.py Прегледај датотеку

@@ -39,6 +39,11 @@ UPDATE_TOOLSET = False
39 39
 WRITENODE_VERSION = 1.0
40 40
 USE_ENV_PROJECT_ROOT = 1
41 41
 WRITENODE_LABEL = 'exr compression: [value compression]'
42
+KELLERTABKNOBS = (
43
+    'extension', 'ext', 'ver', 'explore', 'divider3', 'playinrv', 'pushtorv', 'pushtorvappend', 'divider2', 'ignore',
44
+    'divider1', 'set',
45
+    'info', 'element', 'subtask', 'task', 'w_reload', 'useshotenv', 'keller')
46
+
42 47
 
43 48
 # globals
44 49
 sequenceGlobal=''
@@ -51,18 +56,19 @@ class sceneControl(KellerNukePlugin):
51 56
         self.menu = nuke.menu('Nuke')
52 57
         m = self.menu.addMenu('SceneControl')
53 58
         m.addCommand('SceneControl', 'import sceneControl; sceneControl.createSceneControl()',shortcut='F12')
54
-        m.addCommand('Increment Major', 'import sceneControl; sceneControl.increment_major_version()', tooltip="Increment Major version and save script.", shortcut='alt+shift+s')
55
-        m.addCommand('Increment Minor', 'import sceneControl; sceneControl.increment_minor_version()', tooltip="Increment Minor version and save script.", shortcut='alt+s')
59
+        m.addCommand('Increment Major', 'import sceneControl; sceneControl.increment_major_version()', tooltip='Increment Major version and save script.', shortcut='alt+shift+s')
60
+        m.addCommand('Increment Minor', 'import sceneControl; sceneControl.increment_minor_version()', tooltip='Increment Minor version and save script.', shortcut='alt+s')
56 61
         m.addCommand('Reload Config', 'import sceneControl; sceneControl.kenvDelete()')
57 62
 
58
-        m.addCommand('Helpers/Read/Set Missing Frames Mode', 'import sceneControl; sceneControl.setErrorMode()', tooltip="Sets the Error Mode on selected Read nodes.")
59
-        m.addCommand('Helpers/Read/Set colorspace on Nodes', 'import sceneControl; sceneControl.setOcioRole()', tooltip="Sets the OCIO role on selected Read / Write nodes.")
60
-        m.addCommand('Helpers/Read/Reload Reads', 'import sceneControl; sceneControl.refresh_read_nodes()', tooltip="Reload footage of selected Read / Write nodes.")
63
+        m.addCommand('Helpers/Read/Set Missing Frames Mode', 'import sceneControl; sceneControl.setErrorMode()', tooltip='Sets the Error Mode on selected Read nodes.')
64
+        m.addCommand('Helpers/Read/Set colorspace on Nodes', 'import sceneControl; sceneControl.setOcioRole()', tooltip='Sets the OCIO role on selected Read / Write nodes.')
65
+        m.addCommand('Helpers/Read/Reload Reads', 'import sceneControl; sceneControl.refresh_read_nodes()', tooltip='Reload footage of selected Read / Write nodes.')
61 66
         #
62 67
         m.addCommand('Helpers/Write/Ignore selected Nodes', 'import sceneControl; sceneControl.setIgnoreFlag(True)')
63 68
         m.addCommand('Helpers/Write/Manage selected Nodes','import sceneControl; sceneControl.setIgnoreFlag(False)')
64
-        m.addCommand('Helpers/Write/Set colorspace on Nodes', 'import sceneControl; sceneControl.setOcioRole()', tooltip="Sets the OCIO role on selected Read / Write nodes.")
65
-        m.addCommand('Helpers/Write/Update Write Nodes Tab', 'import sceneControl; sceneControl.updateWriteNodeConfig()', tooltip="Updates Keller Tab and functions of selected write nodes.")
69
+        m.addCommand('Helpers/Write/Set colorspace on Nodes', 'import sceneControl; sceneControl.setOcioRole()', tooltip='Sets the OCIO role on selected Read / Write nodes.')
70
+        m.addCommand('Helpers/Write/Update Write Nodes Tab', 'import sceneControl; sceneControl.updateWriteNodeConfig()', tooltip='Updates Keller Tab and functions of selected write nodes.')
71
+        m.addCommand('Helpers/Write/Remove Write Nodes Tab', 'import sceneControl; sceneControl.removeKellerTab()', tooltip='Removes Keller Tab on selected Write Nodes.')
66 72
 
67 73
         #internal
68 74
         m.addCommand('Debug/Enable Debug Mode', 'import sceneControl; sceneControl.setDebug(True)')
@@ -99,6 +105,7 @@ class sceneControl(KellerNukePlugin):
99 105
         self.menu.removeItem('Helpers/Write/Manage selected Nodes')
100 106
         self.menu.removeItem('Helpers/Write/Set colorspace on Nodes')
101 107
         self.menu.removeItem('Helpers/Write/Update Write Nodes Tab')
108
+        self.menu.removeItem('Helpers/Write/Remove Write Nodes Tab')
102 109
         #
103 110
         self.menu.removeItem('Debug/Enable Debug Mode')
104 111
         self.menu.removeItem('Debug/Disable Debug Mode')
@@ -162,13 +169,11 @@ def onKnobChanged():
162 169
             hexColour = int('%02x%02x%02x%02x' % (1 * 255, 0.666 * 255, 0.266 * 255, 1), 16)
163 170
             n['tile_color'].setValue(hexColour)
164 171
 
165
-
166 172
 def onCreateWrite():
167 173
     n = nuke.thisNode()
168 174
     createCustomWrite(n)
169 175
     return
170 176
 
171
-
172 177
 def onDestroy():
173 178
     print('SceneControl: Info. Nice meeting you. Removing Kenv now...')
174 179
     try:
@@ -179,7 +184,7 @@ def onDestroy():
179 184
 
180 185
 # SceneControl
181 186
 def getSceneControl():
182
-    c = nuke.exists("sceneCtrl")
187
+    c = nuke.exists('sceneCtrl')
183 188
     if c:
184 189
         sc = nuke.toNode('sceneCtrl')
185 190
     else:
@@ -225,14 +230,14 @@ def createSceneControl():
225 230
 
226 231
 
227 232
 def createSceneControlUI():
228
-    n = nuke.Node("NoOp")
229
-    n.setName("sceneCtrl")
233
+    n = nuke.Node('NoOp')
234
+    n.setName('sceneCtrl')
230 235
     n['hide_input'].setValue(True)
231 236
 
232 237
     # % (r * 255, g * 255, b * 255, 1), 16): change r g and b to your liking
233 238
     hexColour = int('%02x%02x%02x%02x' % (0.2 * 255, 0.478 * 255, 0.647 * 255, 1), 16)
234 239
     n['tile_color'].setValue(hexColour)
235
-    n['label'].setValue("_\n__")
240
+    n['label'].setValue('_\n__')
236 241
 
237 242
     # ###########################
238 243
     # ---------------------------
@@ -243,12 +248,6 @@ def createSceneControlUI():
243 248
     k = nuke.Tab_Knob('main', 'Main')
244 249
     n.addKnob(k)
245 250
 
246
-    # Scriptname
247
-    #k = nuke.String_Knob("scriptname", "Script")
248
-    #n.addKnob(k)
249
-    #n.knob("scriptname").setValue(scriptname)
250
-    #n.knob("scriptname").setEnabled(False)
251
-
252 251
     # Project
253 252
     k = nuke.String_Knob('project', 'Project')
254 253
     k.setTooltip('Project Shortname')
@@ -274,8 +273,8 @@ def createSceneControlUI():
274 273
     n.knob('element').clearFlag(nuke.STARTLINE)
275 274
 
276 275
     # Update from KEnv
277
-    k = nuke.PyScript_Knob("reloadConfig", "Reload", "sceneControl.kenvDelete()")
278
-    k.setTooltip("Reload project config file.")
276
+    k = nuke.PyScript_Knob('reloadConfig', 'Reload', 'sceneControl.kenvDelete()')
277
+    k.setTooltip('Reload project config file.')
279 278
     n.addKnob(k)
280 279
 
281 280
     # Season
@@ -291,21 +290,21 @@ def createSceneControlUI():
291 290
     n.knob('episode').setVisible(False)
292 291
 
293 292
     # _______________________________________________________________
294
-    k = nuke.Text_Knob("divider1", "")
293
+    k = nuke.Text_Knob('divider1', '')
295 294
     n.addKnob(k)
296 295
     # _______________________________________________________________
297 296
 
298 297
     # Sequence
299 298
     k = nuke.String_Knob('sequence', 'Seq')
300 299
     k.setTooltip(
301
-        "can be a sequence number or gen when doing generic tasks.\n\ncomp_001_010.comp_v01.ms.nk\ncomp_gen.footageIngest_v01.ms.nk")
300
+        'can be a sequence number or gen when doing generic tasks.\n\ncomp_001_010.comp_v01.ms.nk\ncomp_gen.footageIngest_v01.ms.nk')
302 301
     n.addKnob(k)
303 302
     n.knob('sequence').setValue(seqDef)
304 303
 
305 304
     # Shot
306 305
     k = nuke.String_Knob('shot', 'Shot')
307 306
     k.setTooltip(
308
-        "can be a shot number or gen in a multiShot context.\n\ncomp_001_010.comp_v01.ms.nk\ncomp_001_gen.comp_v01.ms.nk")
307
+        'can be a shot number or gen in a multiShot context.\n\ncomp_001_010.comp_v01.ms.nk\ncomp_001_gen.comp_v01.ms.nk')
309 308
     n.addKnob(k)
310 309
     n.knob('shot').setValue(shotDef)
311 310
     n.knob('shot').clearFlag(nuke.STARTLINE)
@@ -353,7 +352,7 @@ def createSceneControlUI():
353 352
     n.knob('user').clearFlag(nuke.STARTLINE)
354 353
 
355 354
     # Divider _______________________________________________________________
356
-    k = nuke.Text_Knob("divider2", "")
355
+    k = nuke.Text_Knob('divider2', '')
357 356
     n.addKnob(k)
358 357
     # _______________________________________________________________
359 358
 
@@ -380,7 +379,7 @@ def createSceneControlUI():
380 379
     k.setTooltip('Save file Preview.')
381 380
 
382 381
     #  Divider _______________________________________________________________
383
-    k = nuke.Text_Knob("divider3", "")
382
+    k = nuke.Text_Knob('divider3', '')
384 383
     n.addKnob(k)
385 384
     # _______________________________________________________________
386 385
 
@@ -412,81 +411,81 @@ def createSceneControlUI():
412 411
     n.knob('fEnd').clearFlag(nuke.STARTLINE)
413 412
 
414 413
     # Button Get Framerange (ftrack)
415
-    k = nuke.PyScript_Knob("get_framerange", "Get Range", "sceneControl.get_framerange(nuke.thisNode())")
414
+    k = nuke.PyScript_Knob('get_framerange', 'Get Range', 'sceneControl.get_framerange(nuke.thisNode())')
416 415
     n.addKnob(k)
417
-    n.knob("get_framerange").setTooltip("Get Framerange from FTrack.\nPlease check you firewall rules and and allow ftrack ip 104.155.3.128 on port 443")
416
+    n.knob('get_framerange').setTooltip('Get Framerange from FTrack.\nPlease check you firewall rules and and allow ftrack ip 104.155.3.128 on port 443')
418 417
 
419 418
     # Button Set Framerange
420
-    k = nuke.PyScript_Knob("set_framerange", "Set Range", "sceneControl.set_framerange(nuke.thisNode())")
419
+    k = nuke.PyScript_Knob('set_framerange', 'Set Range', 'sceneControl.set_framerange(nuke.thisNode())')
421 420
     n.addKnob(k)
422
-    n.knob("set_framerange").setTooltip("Set Framerange from SceneControl Interface")
423
-    n.knob("set_framerange").clearFlag(nuke.STARTLINE)
421
+    n.knob('set_framerange').setTooltip('Set Framerange from SceneControl Interface')
422
+    n.knob('set_framerange').clearFlag(nuke.STARTLINE)
424 423
 
425 424
     # Comment
426
-    k = nuke.Multiline_Eval_String_Knob("comment", "Comment")
425
+    k = nuke.Multiline_Eval_String_Knob('comment', 'Comment')
427 426
     n.addKnob(k)
428
-    n.knob("comment").setValue(comment)
427
+    n.knob('comment').setValue(comment)
429 428
 
430 429
     # Update / publish
431 430
     if UPDATE_TOOLSET:
432 431
         # Button update Layer
433
-        k = nuke.PyScript_Knob("update_layer", "Update Layer", "sceneControl.update_layer()")
432
+        k = nuke.PyScript_Knob('update_layer', 'Update Layer', 'sceneControl.update_layer()')
434 433
         n.addKnob(k)
435
-        n.knob("update_layer").setFlag(nuke.STARTLINE)
434
+        n.knob('update_layer').setFlag(nuke.STARTLINE)
436 435
     
437 436
         # Button connect all Layers
438
-        k = nuke.PyScript_Knob("autoconnect_layers", "Connect Layers", "sceneControl.autoconnect_layers(nuke.thisNode())")
437
+        k = nuke.PyScript_Knob('autoconnect_layers', 'Connect Layers', 'sceneControl.autoconnect_layers(nuke.thisNode())')
439 438
         n.addKnob(k)
440
-        n.knob("autoconnect_layers").setFlag(nuke.STARTLINE)
439
+        n.knob('autoconnect_layers').setFlag(nuke.STARTLINE)
441 440
     
442 441
         # Button remove all layers
443
-        k = nuke.PyScript_Knob("remove_all_layers", "Remove All Layers", "sceneControl.remove_all_layers(nuke.thisNode())")
442
+        k = nuke.PyScript_Knob('remove_all_layers', 'Remove All Layers', 'sceneControl.remove_all_layers(nuke.thisNode())')
444 443
         n.addKnob(k)
445
-        n.knob("remove_all_layers").setTooltip("Removes all Layers in SceneControl.")
444
+        n.knob('remove_all_layers').setTooltip('Removes all Layers in SceneControl.')
446 445
     
447 446
         # Button delete all reads
448
-        k = nuke.PyScript_Knob("remove_scnctrl_reads", "Delete All Reads",
449
-                               "sceneControl.remove_scnctrl_reads(nuke.thisNode())")
447
+        k = nuke.PyScript_Knob('remove_scnctrl_reads', 'Delete All Reads',
448
+                               'sceneControl.remove_scnctrl_reads(nuke.thisNode())')
450 449
         n.addKnob(k)
451
-        n.knob("remove_scnctrl_reads").setTooltip("Deletes all reads created by SceneControl.")
452
-        n.knob("remove_scnctrl_reads").setFlag(nuke.STARTLINE)
453
-        n.knob("remove_scnctrl_reads").setVisible(False)
450
+        n.knob('remove_scnctrl_reads').setTooltip('Deletes all reads created by SceneControl.')
451
+        n.knob('remove_scnctrl_reads').setFlag(nuke.STARTLINE)
452
+        n.knob('remove_scnctrl_reads').setVisible(False)
454 453
     
455 454
         # Button publish Shot
456
-        k = nuke.PyScript_Knob("publish_shot", "Publish", "sceneControl.publish_shot()")
455
+        k = nuke.PyScript_Knob('publish_shot', 'Publish', 'sceneControl.publish_shot()')
457 456
         n.addKnob(k)
458
-        n.knob("publish_shot").setFlag(nuke.STARTLINE)
457
+        n.knob('publish_shot').setFlag(nuke.STARTLINE)
459 458
 
460 459
     # invisible helpers
461 460
     # helper
462
-    k = nuke.Int_Knob("layerNum", "Slots")
461
+    k = nuke.Int_Knob('layerNum', 'Slots')
463 462
     n.addKnob(k)
464
-    n.knob("layerNum").setValue(0)
465
-    n.knob("layerNum").setVisible(False)
463
+    n.knob('layerNum').setValue(0)
464
+    n.knob('layerNum').setVisible(False)
466 465
 
467 466
     # used for resolving expressions
468
-    k = nuke.EvalString_Knob("eval_helper", "eval_helper")
467
+    k = nuke.EvalString_Knob('eval_helper', 'eval_helper')
469 468
     n.addKnob(k)
470
-    n.knob("eval_helper").setValue("")
471
-    n.knob("eval_helper").setVisible(False)
469
+    n.knob('eval_helper').setValue('')
470
+    n.knob('eval_helper').setVisible(False)
472 471
     # for debug disable above
473 472
 
474
-    k = nuke.Boolean_Knob("stereoToggle", "Stereo Toggle")
473
+    k = nuke.Boolean_Knob('stereoToggle', 'Stereo Toggle')
475 474
     n.addKnob(k)
476
-    n.knob("stereoToggle").setValue(0)
477
-    n.knob("stereoToggle").setVisible(False)
475
+    n.knob('stereoToggle').setValue(0)
476
+    n.knob('stereoToggle').setVisible(False)
478 477
 
479 478
     # used for resolving expressions
480
-    k = nuke.EvalString_Knob("precomp_output", "Precomp Output")
479
+    k = nuke.EvalString_Knob('precomp_output', 'Precomp Output')
481 480
     n.addKnob(k)
482
-    n.knob("precomp_output").setValue("")
483
-    n.knob("precomp_output").setVisible(False)
481
+    n.knob('precomp_output').setValue('')
482
+    n.knob('precomp_output').setVisible(False)
484 483
     # for debug disable above
485 484
 
486
-    k = nuke.Boolean_Knob("debug", "Debug")
485
+    k = nuke.Boolean_Knob('debug', 'Debug')
487 486
     n.addKnob(k)
488
-    n.knob("debug").setValue(1)
489
-    n.knob("debug").setVisible(False)
487
+    n.knob('debug').setValue(1)
488
+    n.knob('debug').setVisible(False)
490 489
 
491 490
     # end helper
492 491
 
@@ -574,7 +573,7 @@ def kenvGetWriteOutput(writeTask, writeElement, writeInfo, ext):
574 573
     k = sceneControl.knobs()
575 574
     kenvCheck()
576 575
     # debug
577
-    if k["debug"].getValue():
576
+    if k['debug'].getValue():
578 577
         print(('SceneControl: Debug. WriteTask: %s, WriteElement: %s, WriteInfo: %s') % (writeTask, writeElement, writeInfo))
579 578
 
580 579
     # useEnvProjectRoot
@@ -587,7 +586,7 @@ def kenvGetWriteOutput(writeTask, writeElement, writeInfo, ext):
587 586
     if writeTask.lower() == 'scripttask':
588 587
         # get task from sceneControl and not from the write node
589 588
         # sceneControl task
590
-        task = k["task"].value()
589
+        task = k['task'].value()
591 590
         writeTask = task
592 591
         # KEnv query
593 592
         renderpath = kenvQuery('RENDER_2D_FILE', element=writeElement, task=writeTask, minor_version=None, info=writeInfo, ext=ext, USE_ENV_PROJECTROOT=useEnv)
@@ -726,7 +725,7 @@ def kenvWriteSetPath(n):
726 725
     k = sceneControl.knobs()
727 726
     kenvCheck()
728 727
     #debug
729
-    if k["debug"].getValue():
728
+    if k['debug'].getValue():
730 729
         print(('SceneControl: Debug. Setting path on: %s') % n.name())
731 730
     subtask = n.knob('subtask').value()
732 731
     if subtask is None:
@@ -769,7 +768,7 @@ def kenvWriteReloadSubTasks(n):
769 768
 def setIgnoreFlag(state):
770 769
     s = nuke.selectedNodes()
771 770
     if len(s) == 0:
772
-        nuke.message("Please select some Nodes first.")
771
+        nuke.message('Please select some Nodes first.')
773 772
         return
774 773
 
775 774
     for n in s:
@@ -783,7 +782,7 @@ def setIgnoreFlag(state):
783 782
 def setErrorMode():
784 783
     n = nuke.selectedNodes()
785 784
     if len(n) == 0:
786
-        nuke.message("Please select some Nodes first.")
785
+        nuke.message('Please select some Nodes first.')
787 786
         return
788 787
     w = nuke.nodes.Read()
789 788
     onerror = w['on_error'].values()
@@ -796,14 +795,14 @@ def setErrorMode():
796 795
 
797 796
     sel = nuke.selectedNodes()
798 797
     for s in sel:
799
-        if s.Class() == "Read" or s.Class() == "DeepRead":
798
+        if s.Class() == 'Read' or s.Class() == 'DeepRead':
800 799
             s.knobs()['on_error'].setValue(ret)
801 800
 
802 801
 
803 802
 def setOcioRole():
804 803
     n = nuke.selectedNodes()
805 804
     if len(n) == 0:
806
-        nuke.message("No node(s) selected.")
805
+        nuke.message('No node(s) selected.')
807 806
 
808 807
     # create temporary write node
809 808
     w = nuke.nodes.Write(file_type='exr')
@@ -828,7 +827,7 @@ def setOcioRole():
828 827
     ret = p.value('Colorspace')
829 828
     if ret is not None:
830 829
         for s in n:
831
-            if s.Class() == "Read" or s.Class() == "Write":
830
+            if s.Class() == 'Read' or s.Class() == 'Write':
832 831
                 s.knobs()['colorspace'].setValue(ret)
833 832
 
834 833
 
@@ -848,12 +847,12 @@ def setDebug(state):
848 847
 
849 848
 def deselectAll():
850 849
     for each in nuke.allNodes():
851
-        each.knob("selected").setValue(False)
850
+        each.knob('selected').setValue(False)
852 851
     return
853 852
 
854 853
 
855 854
 def getFilename():
856
-    return nuke.Root()["name"].getValue()
855
+    return nuke.Root()['name'].getValue()
857 856
 
858 857
 
859 858
 
@@ -861,7 +860,7 @@ def find_node_by_type(nodename, nodeclass):
861 860
     nodes = nuke.allNodes()
862 861
     for n in nodes:
863 862
         if n.Class() == nodeclass:
864
-            if n.knob("label").getValue().lower() == nodename.lower():
863
+            if n.knob('label').getValue().lower() == nodename.lower():
865 864
                 return n
866 865
     return None
867 866
 
@@ -887,23 +886,15 @@ def updateWriteNodeConfig():
887 886
     # TODO: more automated update function.
888 887
     import sceneControl
889 888
 
890
-    # 'task' for legacy write nodes
891
-    customKnobs = (
892
-    'extension', 'ext', 'ver', 'explore', 'divider3', 'playinrv', 'pushtorv', 'pushtorvappend', 'divider2', 'ignore', 'divider1', 'set',
893
-    'info', 'element', 'subtask', 'task', 'w_reload', 'keller')
894
-
895 889
     # save these for reapplying later on
896 890
     saveKnobs = ('info', 'element', 'subtask', 'ignore')
897 891
 
898 892
     # get all reads
899 893
     nodes = [node for node in nuke.selectedNodes() if node.Class() == 'Write']
900 894
 
901
-    for n in nodes:
902
-        knobs = n.knobs()
903
-        info = ''
904
-        element = ''
905
-        subtask = ''
906
-        for c in customKnobs:
895
+    if len(nodes) >0:
896
+        for n in nodes:
897
+            knobs = n.knobs()
907 898
             # save config
908 899
             try:
909 900
                 info = knobs['info'].value()
@@ -912,31 +903,58 @@ def updateWriteNodeConfig():
912 903
                 ignore = knobs['ignore'].value()
913 904
             except:
914 905
                 pass
906
+            for c in KELLERTABKNOBS:
907
+                try:
908
+                    n.removeKnob(knobs[c])
909
+                except:
910
+                    pass
911
+
912
+            # create new Keller tab
913
+            sceneControl.createCustomWrite(n)
914
+
915
+            # refresh subtasks
916
+            sceneControl.kenvWriteReloadSubTasks(n)
917
+
918
+            # restore old values
915 919
             try:
916
-                n.removeKnob(knobs[c])
920
+                n.knobs()['info'].setValue(info)
917 921
             except:
918
-                pass
919
-
920
-        # create new Keller tab
921
-        sceneControl.createCustomWrite(n)
922
+                print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), info)
923
+            try:
924
+                n.knobs()['element'].setValue(element)
925
+            except:
926
+                print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), element)
927
+            try:
928
+                n.knobs()['subtask'].setValue(subtask)
929
+            except:
930
+                print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), subtask)
931
+    else:
932
+        pass
933
+    return
922 934
 
923
-        # refresh subtasks
924
-        sceneControl.kenvWriteReloadSubTasks(n)
925 935
 
926
-        # restore old values
927
-        try:
928
-            n.knobs()['info'].setValue(info)
929
-        except:
930
-            print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), info)
931
-        try:
932
-            n.knobs()['element'].setValue(element)
933
-        except:
934
-            print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), element)
935
-        try:
936
-            n.knobs()['subtask'].setValue(subtask)
937
-        except:
938
-            print('SceneControl: Error. Node %s. Cannot set value on knob: %s') % (n.name(), subtask)
936
+def removeKellerTab():
937
+    # get all reads
938
+    nodes = [node for node in nuke.selectedNodes() if node.Class() == 'Write']
939 939
 
940
+    if len(nodes) >0:
941
+        for n in nodes:
942
+            knobs = n.knobs()
943
+            # save config
944
+            try:
945
+                info = knobs['info'].value()
946
+                element = knobs['element'].value()
947
+                subtask = knobs['subtask'].value()
948
+                ignore = knobs['ignore'].value()
949
+            except:
950
+                pass
951
+            for c in KELLERTABKNOBS:
952
+                try:
953
+                    n.removeKnob(knobs[c])
954
+                except:
955
+                    pass
956
+    else:
957
+        pass
940 958
     return
941 959
 
942 960
 
@@ -956,7 +974,7 @@ def refresh_read_nodes():
956 974
 
957 975
 def autoconnect_layers(node):
958 976
     n = nuke.thisNode()
959
-    nu = n["layerNum"].getValue()
977
+    nu = n['layerNum'].getValue()
960 978
     num = int(nu)
961 979
 
962 980
     for i in range(1, num + 1):
@@ -1055,11 +1073,11 @@ def set_shot():
1055 1073
 def createCustomWrite(n):
1056 1074
     # Task
1057 1075
     '''
1058
-    taskList = ("comp",)
1076
+    taskList = ('comp',)
1059 1077
     try:
1060 1078
         taskList = sceneControl.kenvReloadTasks()
1061 1079
     except:
1062
-        print("Our_Write: Error. Cannot call sceneControl.kenvReloadTasks()")
1080
+        print('Our_Write: Error. Cannot call sceneControl.kenvReloadTasks()')
1063 1081
         pass
1064 1082
     '''
1065 1083
     try:
@@ -1072,7 +1090,7 @@ def createCustomWrite(n):
1072 1090
         # already existing
1073 1091
         return
1074 1092
     # create tab
1075
-    print("Our_Write: Info. Creating KellerTab")
1093
+    print('Our_Write: Info. Creating KellerTab')
1076 1094
     k = nuke.Tab_Knob('keller', 'Keller')
1077 1095
     n.addKnob(k)
1078 1096
 
@@ -1115,35 +1133,35 @@ def createCustomWrite(n):
1115 1133
 
1116 1134
 
1117 1135
     # _______________________________________________________________
1118
-    k = nuke.Text_Knob("divider1", "")
1136
+    k = nuke.Text_Knob('divider1', '')
1119 1137
     n.addKnob(k)
1120 1138
     # _______________________________________________________________
1121 1139
 
1122 1140
     # ignore
1123
-    k = nuke.Boolean_Knob("ignore", "ignore in sceneControl")
1141
+    k = nuke.Boolean_Knob('ignore', 'ignore in sceneControl')
1124 1142
     n.addKnob(k)
1125
-    n.knob("ignore").setValue(0)
1143
+    n.knob('ignore').setValue(0)
1126 1144
 
1127 1145
     # _______________________________________________________________
1128
-    k = nuke.Text_Knob("divider2", "")
1146
+    k = nuke.Text_Knob('divider2', '')
1129 1147
     n.addKnob(k)
1130 1148
     # _______________________________________________________________
1131 1149
 
1132 1150
     # play in new rv
1133
-    k = nuke.PyScript_Knob("playinrv", "Play in RV", "playInRV.playInRV(nuke.thisNode(),0)")
1151
+    k = nuke.PyScript_Knob('playinrv', 'Play in RV', 'playInRV.playInRV(nuke.thisNode(),0)')
1134 1152
     n.addKnob(k)
1135
-    n.knob("playinrv").setTooltip("Opens new instance of RV")
1136
-    n.knob("playinrv").setFlag(nuke.STARTLINE)
1153
+    n.knob('playinrv').setTooltip('Opens new instance of RV')
1154
+    n.knob('playinrv').setFlag(nuke.STARTLINE)
1137 1155
 
1138 1156
     # push to rv
1139
-    k = nuke.PyScript_Knob("pushtorv", "Push to RV", "playInRV.playInRV(nuke.thisNode(),1)")
1157
+    k = nuke.PyScript_Knob('pushtorv', 'Push to RV', 'playInRV.playInRV(nuke.thisNode(),1)')
1140 1158
     n.addKnob(k)
1141
-    n.knob("pushtorv").setTooltip("Push to tagged RV. Will open RV and uses this instance to directly push sequences.")
1159
+    n.knob('pushtorv').setTooltip('Push to tagged RV. Will open RV and uses this instance to directly push sequences.')
1142 1160
 
1143 1161
     # push to rv / append
1144
-    k = nuke.PyScript_Knob("pushtorvappend", "Push to RV (append)", "playInRV.playInRV(nuke.thisNode(),2)")
1162
+    k = nuke.PyScript_Knob('pushtorvappend', 'Push to RV (append)', 'playInRV.playInRV(nuke.thisNode(),2)')
1145 1163
     n.addKnob(k)
1146
-    n.knob("pushtorvappend").setTooltip("Push to RV and append to existing sources")
1164
+    n.knob('pushtorvappend').setTooltip('Push to RV and append to existing sources')
1147 1165
     n.knob("pushtorvappend").clearFlag(nuke.STARTLINE)
1148 1166
 
1149 1167
     k = nuke.Boolean_Knob("useshotenv", "use shot env")

Loading…
Откажи
Сачувај