Command Sequence Class


These interface classes are not intended for direct usage; rather they should be inherited by your own subclass. (See Anatomy of a LightWave Python Plug-in)


class lwsdk.ICommandSequence

Bases: lwsdk.lwsdk.IHandlerFuncs

Proxy of C++ PCore::ICommandSequence class

 process(LWModCommand access) → int

CommandSequence plug-ins are of the "single-shot" type. This is the entry point where CommandSequence-class plug-ins perform all their actions.

The return value indicates the success or failure of the operation. In most cases, you're going to return lwsdk.AFUNC_OK, and indicate processing errors through other means.


class lwsdk.LWModCommand(*args)

Bases: object

Proxy of C++ PCore::LWModCommand class

 argument → char

Users and other plug-ins can invoke your plug-in with arguments, which are stored here as a string. If there are no arguments, then this value will be None.

 data → void

This is an opaque pointer to data used internally by Modeler. Pass this as the first argument to the LWModCommand::lookup(), LWModCommand::execute() and LWModCommand::evaluate() methods.

 editBegin(int pntBuf, int polBuf, EltOpSelect select) → MeshEditOp

Begin a mesh edit. The buffer sizes are used to create temporary buffers associated with each point and polygon. Modeler allocates and frees this memory for you, and you can use it for any per-point or per-polygon data you might need during the edit. Points and polygons are flagged as selected according to the code you pass in the select parameter.

 editBegin2(int pntBuf, int edgeBuf, int polBuf, EltOpSelect select) → MeshEditOp


 evaluate(void data, char command) → int

Issue the command with the name and arguments in the command string. This is an alternative to using LWModCommand::lookup() and LWModCommand::execute(). The command and its arguments are written to a single string and delimited by spaces.

 execute(void data, LWCommandCode cmd, PyObject py_dyna_values, EltOpSelect elt_op_select) → PyObject

Issue the command given by the command code argument. py_dyna_values is an array of DynaValue arguments. The selection determines which geometry will be affected by the command and can be any one of the EltOpSelect codes, except lwsdk.OPSEL_MODIFY.

 lookup(void data, char cmdName) → LWCommandCode

Returns an integer code corresponding to the command name. The command is issued by passing the command code to the LWModCommand::execute() method. Command codes are constant for a given Modeler session, so this only needs to be called once per command, after which the codes can be cached and then used in any number of calls to LWModCommand::execute().


This allows for multiple actions to be classified under a single undo operation. Call this before the first action.


Call this to complete a series of actions that are part of a single undo group.


class lwsdk.CommandSequenceFactory(name, klass)

Bases: lwsdk.lwsdk.ICommandSequenceFactory

Default Python Factory for ICommandSequence



class make_test(lwsdk.ICommandSequence):
    def __init__(self, context):
        super(make_test, self).__init__()

        self._radius = lwsdk.Vector(0.5, 0.5, 0.5)
        self._nsides = 24
        self._nsegments = 12
        self._center = lwsdk.Vector(0.0, 0.0, 0.0)

    # LWCommandSequence -----------------------------------
    def process(self, mod_command):
        cs_options = lwsdk.marshall_dynavalues((self._radius, self._nsides, self._nsegments, self._center))
ServerRecord = { lwsdk.CommandSequenceFactory("LW_PyMakeTest", make_test) : ServerTagInfo }

Table Of Contents

Previous topic

Generic Class

Next topic

Image Loader Class

This Page