1
2
3 import os.path
4
5 import nuke
6 import nukescripts
7
8 kCommandField = 'Command:'
9 last_cmd = ''
10
25
26
27
29 """Adds 1 to the _v## at the end of the script name and saves a new version."""
30 root_name = nuke.toNode("root").name()
31 (prefix, v) = nukescripts.version_get(root_name, "v")
32 if v is None: return
33
34 v = int(v)
35 newFileName = nukescripts.version_set(root_name, prefix, v, v + 1)
36
37 newVersionExists = os.path.exists( newFileName )
38 if newVersionExists:
39 message = "The script version \n%s\nalread exists.\nDo you want to overwrite it?" % newFileName
40 cancelVersionUp = not nuke.ask( message )
41 if cancelVersionUp:
42 return
43
44 nuke.scriptSaveAs(newFileName)
45 if nuke.env['studio']:
46 from hiero.ui.nuke_bridge.nukestudio import addNewScriptVersionToBin
47 addNewScriptVersionToBin(root_name, newFileName)
48
49
51 """ Increments the versioning in the script name and the path of the timeline write nodes, then saves the new version. """
52
53 def _setNodesSelected(nodes, selected):
54 for node in nodes:
55 node.setSelected(selected)
56
57 kTimelineWriteNodeKnobName = "timeline_write_node"
58
59 existingSelection = nuke.selectedNodes()
60 _setNodesSelected(existingSelection, False)
61
62 writeNode = None
63
64
65 timelineWriteNodeKnob = nuke.root().knob(kTimelineWriteNodeKnobName)
66 if timelineWriteNodeKnob is not None:
67 timelineWriteNodeName = timelineWriteNodeKnob.getText()
68 writeNode = nuke.toNode(timelineWriteNodeName)
69 if writeNode is not None:
70 _setNodesSelected([writeNode], True)
71
72
73 nukescripts.version_up()
74 nukescripts.script_version_up()
75
76
77 if writeNode is not None:
78 _setNodesSelected([writeNode], False)
79 _setNodesSelected(existingSelection, True)
80
81
116
117
120
123