def _bootstrap(self): """ Invoked when Nuke is done with building it's UI. This will launch the bootstrap process and start reporting progress. """ # Paranoia. This is in case something goes wrong with the removeOnCreate call. I don't know what # could go wrong, but I don't want the risk or rebootstrapping every single time someone adds a # node. That would be really, really bad. if self._is_bootstrapping: self._logger.warning("Unexpected call to NukeBoostrapper._bootstrap.") return # Unregister from the node event, we're bootstrapping now. self._is_bootstrapping = True nuke.removeOnCreate(self._bootstrap) # We should attempt gather the context that was set in the Nuke session that launched/spawned this # session if we can. If this Nuke session has just been launched via the launch app this env var won't be set. self._previous_ctx_str = os.environ.get("TANK_CONTEXT") self._toolkit_mgr.progress_callback = self._report self._toolkit_mgr.bootstrap_engine_async( os.environ.get("SHOTGUN_ENGINE", "tk-nuke"), self._entity, lambda engine: self._on_finish(), self._on_failure ) self._progress_task.start()
def _bootstrap(self): """ Invoked when Nuke is done with building it's UI. This will launch the bootstrap process and start reporting progress. """ # Paranoia. This is in case something goes wrong with the removeOnCreate call. I don't know what # could go wrong, but I don't want the risk or rebootstrapping every single time someone adds a # node. That would be really, really bad. if self._is_bootstrapping: self._logger.warning( "Unexpected call to NukeBoostrapper._bootstrap.") return # Unregister from the node event, we're bootstrapping now. self._is_bootstrapping = True nuke.removeOnCreate(self._bootstrap) # We should attempt gather the context that was set in the Nuke session that launched/spawned this # session if we can. If this Nuke session has just been launched via the launch app this env var won't be set. self._previous_ctx_str = os.environ.get("TANK_CONTEXT") self._toolkit_mgr.progress_callback = self._report self._toolkit_mgr.bootstrap_engine_async( os.environ.get("SHOTGUN_ENGINE", "tk-nuke"), self._entity, lambda engine: self._on_finish(), self._on_failure, ) self._progress_task.start()
def init_app(self): """ Called as the application is being initialized """ # this app should not do anything if nuke is run without gui. if nuke.env['gui']: # remove callbacks from sharedNuke menu.py nuke.removeOnScriptLoad(nozonscripts.setOCIO) nuke.removeOnScriptSave(nozonscripts.setOCIO) nuke.removeOnCreate(nozonscripts.setOCIOContext, nodeClass='OCIODisplay') # first deal with nuke root settings: we don't need a context for this self._setOCIOSettingsOnRootNode( ) # if I don't do this and do a File/New in Nuke, the new instance of nuke does not set the OCIO settings on the root node. self._add_root_callbacks() self.log_debug("Loading tk-nuke-ocio app.") if self.context.entity is not None: self.event = self.context.entity['name'] self.camera_colorspace = self._getCameraColorspaceFromShotgun() self._setOCIOSettingsOnRootNode() self._setOCIODisplayContext() self._add_callbacks() self.log_debug( "The camera colorspace for '%s' has been fetched from Shotgun and is '%s'" % (self.event, self.camera_colorspace)) else: pass
def _remove_callbacks(self): """ Removed previously added callbacks """ nuke.removeOnUserCreate(self._setOCIOColorspaceContext, nodeClass="OCIOColorSpace") nuke.removeOnCreate(self._setOCIODisplayContext, nodeClass="OCIODisplay") nuke.removeOnCreate(self._warningNoCameraColorspace, nodeClass='Root')
def removeNukeCallback(self): '''remove method from Nuke callback list''' yl.debug('nukeDestroyNodeCallback') if '*' in nuke.onCreates and (self.nukeCreateNodeCallback, (), {}, None) in nuke.onCreates['*']: nuke.removeOnCreate(self.nukeCreateNodeCallback) if '*' in nuke.onDestroys and (self.nukeDestroyNodeCallback, (), {}, None) in nuke.onDestroys['*']: nuke.removeOnDestroy(self.nukeDestroyNodeCallback) if '*' in nuke.knobChangeds or (self.nukeSelectionCallback, (), {}, None) in nuke.knobChangeds['*']: nuke.removeKnobChanged(self.nukeSelectionCallback)
def deleteExpressions(): for node in nuke.allNodes(): if node.knob('motionblur'): node['motionblur'].clearAnimated() node['motionblur'].setValue(0) node['shutter'].clearAnimated() node['shutter'].setValue(0.5) elif node.knob('samples'): node['samples'].clearAnimated() node['samples'].setValue(1) node['shutter'].clearAnimated() node['shutter'].setValue(0.5) nuke.removeOnCreate(addExpr)
def _bootstrap(self): """ Invoked when Nuke is done with building it's UI. This will launch the bootstrap process and start reporting progress. """ # Paranoia. This is in case something goes wrong with the removeOnCreate call. I don't know what # could go wrong, but I don't want the risk or rebootstrapping every single time someone adds a # node. That would be really, really bad. if self._is_bootstrapping: self._logger.warning( "Unexpected call to NukeBoostrapper._bootstrap.") return # Unregister from the node event, we're bootstrapping now. self._is_bootstrapping = True nuke.removeOnCreate(self._bootstrap) self._toolkit_mgr.progress_callback = self._report self._toolkit_mgr.bootstrap_engine_async( os.environ.get("SHOTGUN_ENGINE", "tk-nuke"), self._entity, lambda engine: self._on_finish(), self._on_failure) self._progress_task.start()
def restoreBegin(self): log("restoreBegin") nuke.removeKnobChanged(self.knobChanged) nuke.removeOnCreate(self.onCreate) nuke.removeOnDestroy(self.onDestroy)
def disable(): """Disable patch. """ PatchPrecompDialog.disable() PatchPrecompSelected.disable() nuke.removeOnCreate(_on_precomp_create, nodeClass='Precomp')
def _remove_root_callbacks(self): """ Removed previously added callbacks """ nuke.removeOnCreate(self._setOCIOSettingsOnRootNode, nodeClass='Root') nuke.removeDefaultColorspaceMapper(self._nozonDefaultColorspaceMapper)
def myTracker(): n = nuke.thisNode() int_k = nuke.Int_Knob('timeOffset_val', '') txt_k = nuke.Text_Knob('timeOffset', '') txt_k.setLabel('Time Offset') pyBtn_k = nuke.PyScript_Knob('timeOffset_btn', 'apply Time offset') pyBtn_k.clearFlag(nuke.STARTLINE) pyBtn_k.setCommand( "if(nuke.thisNode().knob('tracks').value() != 0.0):\n\tnuke.thisNode().knob('tracks').setExpression(\"curve(frame+(this.timeOffset_val)*-1)\")\nelse:\n\tnuke.message('No tracks found on this tracker node!')" ) if not n.knob(int_k.name()) and not n.knob(txt_k.name()): n.addKnob(txt_k) n.addKnob(int_k) n.knob(int_k.name()).setValue(1) n.addKnob(pyBtn_k) #'Tracker4' custom default knob values #---------------------------------------- n.knob('pretrack_filter').setValue('none') n.knob('max_error').setValue(0.1) n.knob('warp').setValue('srt') n.knob('label').setValue( "reference_frame==[format %03d [value this.knob.reference_frame]]") nuke.addOnCreate(myTracker, nodeClass="Tracker4") nuke.removeOnCreate(myTracker)
def restoreBegin (self) : log ("restoreBegin") nuke.removeKnobChanged (self.knobChanged) nuke.removeOnCreate (self.onCreate) nuke.removeOnDestroy (self.onDestroy)
def _remove_callbacks(self): """ Removed previously added callbacks """ nuke.removeOnCreate(self._setOCIODisplayContext, nodeClass="OCIODisplay")
def _remove_root_callbacks(self): """ Removed previously added callbacks """ nuke.removeOnCreate(self._setOCIOSettingsOnRootNode, nodeClass='Root')
def __removeCallbacks(self): ''' Call this method when the UI is being closed in order to remove any callbacks to update the UI which will no longer be required''' nuke.removeOnCreate(self.updateNodeTree) # Remove callback responsible for updating the UI when nodes are created nuke.removeOnDestroy(self.updateNodeTree) # Remove callback responsible for updating the UI when nodes are destroyed