def _addPreKnobs(self): self._flipbookEnum = nuke.Enumeration_Knob( "flipbook", "Flipbook", flipbooking.gFlipbookFactory.getNames()) self._state.setKnob(self._flipbookEnum, "FrameCycler") self.addKnob(self._flipbookEnum) self._viewerForSettings = nuke.Enumeration_Knob( "viewer_settings", "Take settings from", ["-"] + self._viewers.keys()) if not self._takeNodeSettings: self._viewerForSettings.setValue("-") self.addKnob(self._viewerForSettings) self._defaultValues = nuke.PyScript_Knob("default", "Defaults") self.addKnob(self._defaultValues) # Region of Interest knobs self._useRoi = nuke.Boolean_Knob("use_roi", "Enable ROI") self._useRoi.setFlag(nuke.STARTLINE) self._state.setKnob(self._useRoi, False) self.addKnob(self._useRoi) self._roi = nuke.BBox_Knob("roi", "Region of Interest") self._state.setKnob(self._roi, (0, 0, 0, 0)) self.addKnob(self._roi) self._roi.setVisible(self._useRoi.value()) # Channel knobs self._channels = nuke.Channel_Knob("channels_knob", "Channels") if self._node.Class() == "Write": self._channels.setValue(self._node.knob("channels").value()) else: self._state.setKnob(self._channels, "rgba") self._channels.setFlag(nuke.STARTLINE | nuke.NO_CHECKMARKS) self.addKnob(self._channels)
def __init__( self ): panels.PythonPanel.__init__( self, "Precomp Nodes", "uk.co.thefoundry.PrecompOptionsDialog" ) self.scriptPath = nuke.File_Knob( "script", "Precomp script path " ) self.renderPath = nuke.File_Knob( "render", "Precomp render path " ) self.channels = nuke.Channel_Knob( "channels", "Channels " ) self.origNodes = nuke.Enumeration_Knob( "orig", "Original nodes ", ["add backdrop", "delete", "no change" ] ) self.addKnob ( self.scriptPath ) self.addKnob ( self.renderPath ) self.addKnob ( self.channels ) self.addKnob ( self.origNodes ) self.channels.setValue('all') defaultDir = nuke.Root()['name'].value() if defaultDir and defaultDir != "": defaultDir = os.path.dirname( defaultDir ) if not defaultDir.endswith("/"): defaultDir += "/" else: defaultDir = "" basename = findNextName("Precomp") self.scriptPath.setValue( defaultDir + basename + "_v01.nk" ) self.renderPath.setValue( defaultDir + basename + ".####.exr" ) self.setMinimumSize( 420, 50 )
def __setup_knobs(self): self.__output_path_knob = nuke.File_Knob('output_path', 'Output Path') self.addKnob(self.__output_path_knob) self.__file_formats_knob = nuke.Enumeration_Knob('format', 'Format', ['png', 'jpg']) self.addKnob(self.__file_formats_knob) self.__start_frame_knob = nuke.Int_Knob('start_frame', 'Start Frame') self.addKnob(self.__start_frame_knob) self.__end_frame_knob = nuke.Int_Knob('end_frame', 'End Frame') self.addKnob(self.__end_frame_knob) self.__output_channels_knob = nuke.Channel_Knob('output_channels', 'Output Channels') self.__output_channels_knob.setFlag(nuke.ENDLINE) self.__output_channels_knob.setValue('rgba') self.addKnob(self.__output_channels_knob) self.__use_proxy_knob = nuke.Boolean_Knob('use_proxy', 'Use Proxy') self.__use_proxy_knob.setFlag(nuke.ENDLINE) self.addKnob(self.__use_proxy_knob) self.__render_button_knob = nuke.PyScript_Knob('render', 'Render') self.__render_button_knob.setFlag(nuke.STARTLINE) self.addKnob(self.__render_button_knob) self.addKnob(nuke.Text_Knob('copyright', 'www.ngreen.org'))
def __init__(self, nodes=None): super(MultiEdit, self).__init__(b'多节点编辑', self.widget_id) nodes = nodes or nuke.selectedNodes() assert nodes, 'Nodes not given. ' nodes = same_class_filter(nodes) self.nodes = nodes self._values = {} knobs = nodes[0].allKnobs() self.addKnob(nuke.Text_Knob('', b'以 {} 为模版'.format(nodes[0].name()))) self.addKnob(nuke.Tab_Knob('', nodes[0].Class())) def _tab_knob(): if label is None: new_k = nuke.Tab_Knob(name, label, nuke.TABENDGROUP) elif label.startswith('@b;'): new_k = nuke.Tab_Knob(name, label, nuke.TABBEGINGROUP) else: new_k = knob_class(name, label) return new_k for k in knobs: name = k.name() label = k.label() or None knob_class = getattr(nuke, type(k).__name__) if issubclass(knob_class, (nuke.Script_Knob, nuke.Obsolete_Knob)) \ or knob_class is nuke.Knob: continue elif issubclass(knob_class, nuke.Channel_Knob): new_k = nuke.Channel_Knob(name, label, k.depth()) elif issubclass(knob_class, nuke.Enumeration_Knob): enums = [k.enumName(i) for i in range(k.numValues())] new_k = knob_class(name, label, enums) elif issubclass(knob_class, nuke.Tab_Knob): new_k = _tab_knob() elif issubclass(knob_class, nuke.Array_Knob): new_k = knob_class(name, label) new_k.setRange(k.min(), k.max()) else: # print(knob_class, name, label) new_k = knob_class(name, label) transfer_flags(k, new_k) try: new_k.setValue(k.value()) except TypeError: pass self.addKnob(new_k) self.addKnob(nuke.EndTabGroup_Knob('')) self._rename_knob = nuke.EvalString_Knob('', b'重命名') self.addKnob(self._rename_knob) self.addKnob(nuke.ColorChip_Knob('tile_color', b'节点颜色')) self.addKnob(nuke.ColorChip_Knob('gl_color', b'框线颜色')) k = nuke.PyScript_Knob('ok', 'OK') k.setFlag(nuke.STARTLINE) self.addKnob(k) self.addKnob(nuke.PyScript_Knob( 'cancel', 'Cancel', 'nuke.tabClose()'))