Created
July 19, 2013 08:35
-
-
Save yamahigashi/6037643 to your computer and use it in GitHub Desktop.
#softimage PlayControl.Key manipulation plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------# | |
#---------------------------------------------------------------------# | |
#---------------------------------------------------------------------# | |
import time | |
import win32api as win | |
from win32com.client import constants as c | |
#---------------------------------------------------------------------# | |
#------For Instantination---------------------------------------------# | |
#---------------------------------------------------------------------# | |
xsi = Application | |
FASTPLAYBACK_CACHESIZE = 9000 # kb/frame | |
KEYREPEAT_MARGIN = 0.5 | |
GIZMO_RATE = 3 | |
pc = lambda: xsi.Dictionary.GetObject("PlayControl") | |
greenkey = lambda: pc().Parameters("Key") | |
#---------------------------------------------------------------------# | |
#---------- Register XSI PluginManager--------------------------------# | |
#---------------------------------------------------------------------# | |
def XSILoadPlugin(in_reg): | |
in_reg.Author = "anamorphobia" | |
in_reg.Name = "green timeline" | |
in_reg.Email = "yamahigashi@gmail.com" | |
in_reg.URL = "" | |
in_reg.Major = 0 | |
in_reg.Minor = 1 | |
in_reg.RegisterCommand("gsx_next_greenkey") | |
in_reg.RegisterCommand("gsx_prev_greenkey") | |
return True | |
def XSIUnloadPlugin(in_reg): | |
strPluginName = in_reg.Name | |
Application.LogMessage(str(strPluginName) + str(" has been unloaded.")) | |
return True | |
############################################################################### | |
def gsx_next_greenkey_Init(ctxt): | |
cmd = ctxt.Source | |
#cmd.SetFlag(c.siNoLogging, True) | |
def gsx_prev_greenkey_Init(ctxt): | |
cmd = ctxt.Source | |
#cmd.SetFlag(c.siNoLogging, True) | |
#cmd.SetFlag(c.siAllowNotifications, False) | |
def gsx_next_greenkey_Execute(): | |
xsi.SetValue("preferences.scripting.cmdlog", False, "") | |
NextFrame() | |
ks = win.GetKeyboardState() | |
pushed_code = [i for i in range(0x20, 0x8F) if ord(ks[i]) > 1] | |
press_start = time.time() | |
while win.GetAsyncKeyState(pushed_code[0]) \ | |
and time.time() < press_start + KEYREPEAT_MARGIN: | |
pass | |
prev_time = time.time() | |
while win.GetAsyncKeyState(pushed_code[0]): | |
current_time = time.time() | |
if current_time - prev_time < 0.01666: | |
time.sleep(0.4) | |
xsi.Refresh() | |
xsi.Desktop.RedrawUI() | |
#win.SetForegroundWindow(xsi) | |
xsi.Refresh() | |
NextFrame() | |
prev_time = current_time | |
xsi.Refresh() | |
xsi.SetValue("preferences.scripting.cmdlog", True, "") | |
def gsx_prev_greenkey_Execute(): | |
xsi.SetValue("preferences.scripting.cmdlog", False, "") | |
PrevFrame() | |
ks = win.GetKeyboardState() | |
pushed_code = [i for i in range(0x20, 0x8F) if ord(ks[i]) > 1] | |
press_start = time.time() | |
while win.GetAsyncKeyState(pushed_code[0]) \ | |
and time.time() < press_start + KEYREPEAT_MARGIN: | |
pass | |
prev_time = time.time() | |
while win.GetAsyncKeyState(pushed_code[0]): | |
current_time = time.time() | |
if current_time - prev_time < 0.01666: | |
time.sleep(0.4) | |
xsi.Refresh() | |
PrevFrame() | |
prev_time = current_time | |
xsi.Refresh() | |
xsi.SetValue("preferences.scripting.cmdlog", True, "") | |
def PrevFrame(): | |
greenkey().Value = greenkey().Value - 1 | |
def NextFrame(): | |
greenkey().Value = greenkey().Value + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment