def load(plugin_path): if os.name == 'nt': env_path = ';%s' % plugin_path else: env_path = ':%s' % plugin_path maya_plugin_path = mel.eval('getenv "MAYA_PLUG_IN_PATH"') if plugin_path not in maya_plugin_path: mel.eval('putenv "MAYA_PLUG_IN_PATH" "' + maya_plugin_path + env_path + '"') if cmds.pluginInfo(plugin_name, q=True, r=True): try: cmds.unloadPlugin(plugin_name, force=True) except Exception as e: logging.exception(e) sys.path.append(plugin_path) try: import tweener reload(tweener) tweener.reload_mods() except Exception as e: logging.exception(e) try: cmds.loadPlugin(plugin_name) if cmds.pluginInfo(plugin_name, q=True, r=True): cmds.pluginInfo(plugin_name, e=True, autoload=True) except Exception as e: logging.exception(e) try: cmds.tweener() except Exception as e: cmds.warning('Could not execute tweener command: %s' % str(e)) answer = cmds.confirmDialog( t='Tweener Installed!', m='Tweener was installed at:\n' '%s\n\n' 'Would you like to add a shelf button to the current shelf?' % plugin_path, button=['Yes', 'No'], db='Yes', cb='No', ds='No') if answer == 'Yes': try: tweener.ui.add_shelf_button(path=plugin_path) except Exception as e: logging.exception(e) sys.stdout.write( '# Tweener install completed! See the Script Editor for more information.\n' )
def fraction_clicked(self, value): value = value * 2.0 - 1.0 self.interpolation_mode = self.mode_button_group.checkedButton().mode() cmds.undoInfo(openChunk=True, chunkName="tweener") try: cmds.tweener(t=value, newCache=True, type=self.interpolation_mode.idx) # cmds.tweener(t=value, newCache=False, type=self.interpolation_mode.idx) finally: cmds.undoInfo(closeChunk=True)
def release(self): """ Dragger context release event handler. """ blend = self.get_blend() if self.live_preview: cmds.tweener(t=blend, newCache=False, type=self.interpolation_mode.idx) else: cmds.tweener(t=blend, newCache=True, type=self.interpolation_mode.idx) cmds.refresh()
def slider_released(self): self.dragging = False slider_value = self.slider.value() blend = slider_value / 100.0 if self.live_preview: cmds.tweener(t=blend, newCache=False, type=self.interpolation_mode.idx) else: cmds.tweener(t=blend, newCache=True, type=self.interpolation_mode.idx) self.slider.setValue(0) self.slider_label.setText('') om.MEventMessage.removeCallback(self.idle_callback)
def slider_pressed(self): self.dragging = True slider_value = self.slider.value() blend = slider_value / 100.0 self.interpolation_mode = self.mode_button_group.checkedButton().mode() # only update when maya is idle to prevent multiple calls without seeing the result self.idle_callback = om.MEventMessage.addEventCallback('idle', self.slider_changed) if self.live_preview: # disable undo on first call, so we don't get 2 undos in queue # both press and release add to the same cache, so it should be safe cmds.undoInfo(stateWithoutFlush=False) cmds.tweener(t=blend, newCache=True, type=self.interpolation_mode.idx) cmds.undoInfo(stateWithoutFlush=True) tween.interpolate(blend=blend, mode=self.interpolation_mode)
def press(self): """ Dragger context press event handler. Gets the initial position and reads in the available options. An initial interpolation is also performed. """ self.press_position = cmds.draggerContext('tweenerToolContext', q=True, anchorPoint=True) self.interpolation_mode = options.load_interpolation_mode() self.overshoot = options.load_overshoot() self.live_preview = options.load_live_preview() # disable undo on first call, so we don't get 2 undos in queue # both press and release add to the same cache, so it should be safe if self.live_preview: cmds.undoInfo(stateWithoutFlush=False) cmds.tweener(t=0.0, newCache=True, type=self.interpolation_mode.idx) cmds.undoInfo(stateWithoutFlush=True) tween.interpolate(blend=0.0, mode=self.interpolation_mode) cmds.refresh()