def __init__(self): import nuke.rotopaint super(RotoViewsPanel, self).__init__('Change views on RotoPaint Nodes...') self.changeKnob = nuke.Enumeration_Knob( 'change', 'change', ['all RotoPaint nodes', 'selected RotoPaint nodes']) self.addKnob(self.changeKnob) self.viewsKnob = nuke.MultiView_Knob('views') self.addKnob(self.viewsKnob) self.viewsKnob.setValue((' ').join(nuke.views())) self.okButton = nuke.Script_Knob("Change Views") self.addKnob(self.okButton) self.okButton.setFlag(nuke.STARTLINE) self.cancelButton = nuke.Script_Knob("Cancel") self.addKnob(self.cancelButton)
def _addViewKnob(self): oc = nuke.OutputContext() self._views = [oc.viewname(i) for i in xrange(1, oc.viewcount())] if (oc.viewcount() > 2): supportedViews = self._selectedFlipbook().capabilities( )["maximumViews"] if (int(supportedViews) > 1): self._viewSelection = nuke.MultiView_Knob("views", "Views") else: self._viewSelection = nuke.OneView_Knob( "views", "View", self._views) activeView = nuke.activeViewer().view() if activeView == "": activeView = self._views[0] # Retrieve previous view selection or default to selecting all available views previousViews = self._state.getValue( self._viewSelection.name(), " ".join(self._views)).split() # Get the intersection of the previous selection and the available views viewsToRestore = set(self._views).intersection(previousViews) if viewsToRestore: self._viewSelection.setValue(" ".join(viewsToRestore)) else: self._viewSelection.setValue(activeView) self.addKnob(self._viewSelection) self._viewSelection.clearFlag(nuke.NO_MULTIVIEW)
def _addViewKnob(self): """Add knobs for view selection.""" oc = nuke.OutputContext() if (oc.viewcount() > 2): self._viewSelection = nuke.MultiView_Knob("multi_view", "Views") self._viewSelection.fromScript( self._state.get(self._viewSelection, self._getDefaultViews())) self.addKnob(self._viewSelection) self._viewSelection.clearFlag(nuke.NO_MULTIVIEW)
def _addViewKnob(self): oc = nuke.OutputContext() self._views = [oc.viewname(i) for i in xrange(1, oc.viewcount())] if (oc.viewcount() > 2): supportedViews = self._selectedFlipbook().capabilities( )["maximumViews"] if (int(supportedViews) > 1): self._viewSelection = nuke.MultiView_Knob("views", "Views") else: self._viewSelection = nuke.OneView_Knob( "views", "View", self._views) activeView = nuke.activeViewer().view() if activeView == "": activeView = self._views[0] self._state.setKnob(self._viewSelection, activeView) self.addKnob(self._viewSelection) self._viewSelection.clearFlag(nuke.NO_MULTIVIEW)