babylondreams.commander package

Submodules

babylondreams.commander.Commander module

class babylondreams.commander.Commander.CommanderClass[source]

Bases: lxu.command.BasicCommand

Wrapper for lxu.command.BasicCommand. Improves and simplifies common command UI implementations, like popups, sPresetText fields, and Form Command Lists. Allows for virtually any type of command.

See README.md for more examples.

# Extend the commander.CommandClass class MyGreatCommandClass(commander.CommandClass):

# Optional method returns any command argument definitions

commander_arguments(self):
return[{
commander.NAME: ‘myStringArgument’, commander.DATATYPE: ‘string’

}]

# Required method contains the actual command code. # Note: traceback is included by default; no need to add.

commander_execute(self):
args = commander_args() lx.out(args[‘myStringArgument’])

# Bless the class as normal. lx.bless(MyGreatCommandClass, “myGreatCommand”)

arg_UIHints(index, hints)[source]

Adds pretty labels to arguments in command dialogs. If no label parameter is explicitly included, we create a pseudo-label by capitalizing the argument name and replacing underscores with spaces.

Labels can either be literal strings or method/function objects. In the latter case, the method or function will be called when needed.

If any popup fields of type sPresetText are present, adds the appropriate hint.

You should never need to touch this.

arg_UIValueHints(index)[source]

Popups and sPresetText arguments fire this method whenever they update. Note that the ‘hints’ parameter can be a literal list or tuple, but can also be a method or function.

For dynamic lists, be sure to pass in the generator method or function object itself, not its result. (i.e. pass in ‘myGreatFunction’, NOT ‘myGreatFunction()’)

You should never need to touch this.

basic_Execute(msg, flags)[source]

Stores recent command values for next run and wraps commander_execute in a try/except statement with traceback.

Do NOT override this method. Use commander_execute() instead.

You should never need to touch this.

cmd_DialogInit()[source]

Sets default values for arguments in command dialogs as explained in __init__() above. If you change this, you run the risk of causing the universe to implode on itself.

You should never need to touch this.

cmd_Flags()[source]

Set command flags. This method can be overridden if special flags are needed.

cmd_NotifyAddClient(argument, object)[source]

Add notifier clients as needed. You should never need to touch this.

cmd_NotifyRemoveClient(object)[source]

Remove notifier clients as needed. You should never need to touch this.

cmd_Query(index, vaQuery)[source]

Returns a value when a queriable argument is queried. It’s a bit weird to use, so commander wraps it up for you. Implement commander_query in your own sublcass to and return whatever you like based on the arg_index.

You should never need to touch this.

commander_arg_value(index, default=None)[source]

Return a command argument value by index. If no argument value exists, returns the default parameter.

NOTE: The commander_args() method is simpler to use than this method. You should probably use that one unless you have a reason to find a specific argument by index.

Parameters:
  • index – (int) index of argument to retrieve
  • default – value to return if argument is not set
Returns:

argument value (str, int, float, or boolean as appropriate)

commander_args()[source]

Returns a dictionary of arguments in name:value pairs.

commander_arguments()[source]

To be overridden by subclasses. Should return a list of dictionaries, one for each argument.

classmethod commander_default_values_init()[source]

Initialize the class variable _commander_stored_values. You should never need to touch this.

classmethod commander_default_values_set(value)[source]

Add an argument to the class variable _commander_stored_values. You should never need to touch this.

commander_execute(msg, flags)[source]

To be overridden by subclasses. This is the main command execution code. It is already wrapped in a try/except statement with traceback, so you don’t need to add that.

commander_notifiers()[source]

To be overridden by subclasses. Should return a list of tuples, e [(‘notifier.editAction’,’‘), (“select.event”, “item +ldt”), (“tagger.notifier”, “”)]

commander_query(arg_index)[source]

To be overridden by subclasses. Should return a value based on the arg_index being queried. For toggle buttons and checkmarks, this should be a boolean. Can also return strings or floats as required.

class babylondreams.commander.Commander.FormCommandListClass(items)[source]

Bases: lxifc.UIValueHints

Special class for creating Form Command Lists. This is instantiated by CommanderClass objects if an FCL argument provided.

Expects a list of valid MODO commands to be provided to init.

NOTE: Any invalid command will crash MODO.

You should never need to touch this.

uiv_Flags()[source]
uiv_FormCommandListByIndex(index)[source]
uiv_FormCommandListCount()[source]
class babylondreams.commander.Commander.PopupClass(items)[source]

Bases: lxifc.UIValueHints

Special class for creating popups and sPresetText fields. Accepts either a simple list of values, or a list of (ugly, pretty) tuples:

[1, 2, 3] or [(1, “The Number One”), (2, “The Number Two”), (3, “The Number Three”)]

You should never need to touch this.

uiv_Flags()[source]
uiv_PopCount()[source]
uiv_PopInternalName(index)[source]
uiv_PopUserName(index)[source]

babylondreams.commander.MeshEditor module

class babylondreams.commander.MeshEditor.MeshEditorClass(args=None, mesh_edit_flags=[])[source]
do_mesh_edit()[source]
do_mesh_read()[source]
get_active_polys()[source]
get_active_polys_by_island()[source]
get_selected_polys()[source]
get_selected_polys_by_flood(i_POLYTAG=None)[source]
get_selected_polys_by_island()[source]
mesh_edit(read_only=False)[source]

Adapted from James O’Hare’s excellent code: https://gist.github.com/Farfarer/31148a78f392a831239d9b018b90330c

mesh_edit_action()[source]
mesh_read_action()[source]
class babylondreams.commander.MeshEditor.PolysByConnectedClass(polygon, edge, mark_mode_valid, mark_mode_checked)[source]

Bases: lxifc.Visitor

getIslands()[source]
getPolyIDs()[source]
reset()[source]
vis_Evaluate()[source]
class babylondreams.commander.MeshEditor.PolysByIslandClass(polygon, point, mark)[source]

Bases: lxifc.Visitor

vis_Evaluate()[source]
class babylondreams.commander.MeshEditor.PolysByTagFloodClass(polygon, edge, mark_mode_valid, i_POLYTAG)[source]

Bases: lxifc.Visitor

getPolyIDs()[source]
reset()[source]
vis_Evaluate()[source]
class babylondreams.commander.MeshEditor.PolysClass(polygon, edge, mark_mode_valid)[source]

Bases: lxifc.Visitor

getPolyIDs()[source]
reset()[source]
vis_Evaluate()[source]
class babylondreams.commander.MeshEditor.SetMarksClass(acc, mark)[source]

Bases: lxifc.Visitor

vis_Evaluate()[source]

babylondreams.commander.Var module

Module contents