util module

A collection of support tools, decorators, functions etc used by the other modules in the package.



selects an item class constructor based on the item type passed as an argument and returns that as a class instantiation ‘function’ object to call the correct class in methods that eg select by item type or return items. In essence it acts as a sort of clearing house to try to ensure that any recognised but unwrapped items are wrapped with the correct modo.item.xxx type before being returned.

example usage:

# get a list of all the light items in a scene where each light in the list is returned as the correctly
# wrapped modo version of each light sub-type.
import modo
scene = modo.Scene()
lights = []
for light in scene.ItemList(modo.c.LIGHT_TYPE):
    func = modo.c.typeToFunc(light.Type())

# or more succinctly as a list comprehension:
lights = [modo.c.typeToFunc(light.Type())(light) for light in scene.ItemList(modo.c.LIGHT_TYPE)]

modo.util.makeQuickCommand(name, func, arguments=None, userName='myCmdName', description='This command ...', toolTip='Tooltip')[source]

Quick way to create a command.

Note that a command can only be blessed (registered) once per modo session, so this command will fail when attempting to rebless a command.

  • name (string) – Name that the command will be callable by. Example: cmds.myCommand
  • func (function) – The function that the command should call
  • arguments (iterable) – A sequence of name:defaultvalue pairs to make arguments that will be passed on to the function
  • userName (basestring) – The user name
  • description (basestring) – Summary of the command’s purpose
  • toolTip (basestring) – Text that appears when hovering over the button


import modo

def func_args(mystring, myint):
    print mystring, myint

def func_simple():
    print 'simple function, no arguments'

modo.util.makeQuickCommand('test.simple', func_simple)
modo.util.makeQuickCommand('test.args', func_args, (('mystring', 'mesh021'), ('myint', 23)))

lx.eval('test.args mesh022 24')


Access to various system paths.

Parameters:key (basestring) – Specific path to return. Returns all if None.
Returns dictionary or string:
 Dictionary containing all paths or single path as string



Decorator - ensures that the argument passed as the first parameter to a function is an instance of the modo Item class. Should only only be used to decorate methods where the first argument is meant to be an item and ensures that if for any reason an item of either type lx.object.Item or lxu.object.Item gets passed to the method it will get wrapped as an modo.item.Item object before being used.