__all__ = ['CallScriptCustom', 'instantiate']
from ActionRegistry import theActionRegistry
from MessageInterpreter import MessageInterpreter
from RTFapi import Event
from ScriptRunner import ScriptRunner
from UserCustomization import UserCustomBase, CustomInfo
class SynchronizedScript( ScriptRunner ):
def __init__( self, scriptName, args ):
ScriptRunner.__init__( self, scriptName, args )
def Main( self ):
self.sendMessageSync( 'STATUSBAR_SET_TEXT',
(("Example Script"),))
class CallScriptBatch:
def instantiate( self, scriptName, args ):
return SynchronizedScript( scriptName, args )
class CallScriptCustom (UserCustomBase):
def __init__(self):
self.__myCallMenu = None
self.__myCallId = None
self.__myInterpreter = LocalInterpreter()
def getInterpreter(self,isInteractive):
if isInteractive:
return self.__myInterpreter
return None
def appendMenuItems(self,id,menu):
if "Edit" == id:
self.__myCallMenu = menu
self.__myCallId = menu.appendItem(_( 'Call Script\tQ' ),
self.__onCallScript )
theActionRegistry.register( 'Global',
Event.BUTTON_q, (), True,
Event.BUTTONUP,
'CallScript' )
theActionRegistry.register( 'Spectating',
Event.BUTTON_q, (), True,
Event.BUTTONUP,
'CallScript' )
def enableMenuStates(self,id,enableStates):
if "Edit" == id:
enableStates[self.__myCallId] = True
def __onCallScript( self, event ):
self.__myInterpreter.CallScript( event )
class LocalInterpreter( MessageInterpreter ):
def __init__( self ):
MessageInterpreter.__init__( self )
def CallScript( self, event ):
module = CallScriptBatch()
self.sendMessage( "EXECUTE_MODULE", ("Doc", module) )
def instantiate():
return CallScriptCustom()
def info():
customInfo = CustomInfo()
customInfo.vendor = 'Autodesk'
customInfo.version = '2.0'
customInfo.api = '2013'
customInfo.shortInfo = "A sample add-in to call a batch script."
customInfo.longInfo = \
"""To go with the addition of EXECUTE_MODULE, the sample add-in allows us to call a batch \
script with blocking message processing.
"""
return customInfo