Customize Executable#
This example plugin modifies how a specific filetype gets opened when double clicking it in the Project Browser.
In this case it will use the
os.startfile
function to open .lxo files (Modo scenefiles). The plugin can be modified for other filetypes.It allows to force a specific executable or to pass additional arguments to the executable.
See the section for Single File Plugins on how to load this example.
# CustomizeExecutable.py
name = "CustomizeExecutable"
classname = "CustomizeExecutable"
import os
class CustomizeExecutable:
def __init__(self, core):
self.core = core
self.version = "v1.0.0"
# patch the openFile function
self.core.plugins.monkeyPatch(self.core.openFile, self.openFile, self, force=True)
def openFile(self, filepath):
# split the fileextension from the filename
base, ext = os.path.splitext(filepath)
# check if file is a Modo scenefile
if ext == ".lxo":
# launch the scenefile with the startfile function
os.startfile(filepath)
# alternative
# subprocess.Popen(["C:/path/to/my.exe", filepath], env=self.core.startEnv)
else:
# call the original openFile function
self.core.plugins.callUnpatchedFunction(self.core.openFile, filepath)