Anatomy of a LightWave Python Plugin
Python plug-ins using the first-tier integration (see Introduction are built directly atop the LightWave SDK. This means that, in the Python environment, LightWave plug-ins are constructed in a fashion that is quite similar to that of native code plug-ins (C/C++).
‘Hello, Worlds!’
Before we delve exclusively into the realm of Python, let’s see a brief comparison of a LightWave plug-in written in standard C to one that performs the same action written purely in Python.
We shall use the time-honoured Hello, World example for our purposes to keep the code as short as possible, and we’ll use the Generic Class
as our functional plug-in architecture.
‘Hello’ - C
In the following C example, you have what is probably the shortest LightWave plug-in possible (of course, this could be a bit longer, but we have omitted unnecessary elements, like comments, for the sake of the example). All it does is post a prefabricated informational dialog with the text ‘Hello, World!’ displayed.
While the individual lines may seem like Greek, it does illustrate the minimum amount of code required to actually produce a LightWave plug-in (usefulness notwithstanding).
'Hello' - Python
The corresponding LightWave Python plug-in would look like this (as with the C example, only the minimum elements that absolutely must be present for the script to function are included):
As you can see, in terms of lines of code, the Python version is on par with that of the C version. Most elements are Python-specific in nature, relating more to the idioms of the language.
But now, let’s examine a full-blown LightWave Python plug-in in all its gory details. Click here.