Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
'''
This sample Python plugin demonstrates how to use notifiers in Python.
To use, embed the command in a form and change item selection, the command
should update.
'''
@mattcox
mattcox / helloWorld_cmd.py
Last active December 30, 2015 08:39
"Hello World!" - Demonstrates the very basics needed for a command. This will print "Hello World!" to the event log. The command will only be enabled if an item is selected, if there is no selection, then the command will be disabled.
#python
'''
Hello World!
This example demonstrates the very basics needed for a command. Firing
the command prints "Hello World!" to the event log. The command includes
enable and disable states, controlled by the selection. If an item
is selected, the command will be enabled, if not, it won't be.
@mattcox
mattcox / query_cmd.py
Last active December 30, 2015 08:39
Demonstrates how to write an executable and queryable command. This will query a channel value on the first selected item, inputting a value will update the channel and querying the value will show the current value of the channel. The command will only be enabled if an item is selected, if there is no selection, then the command will be disabled.
#python
'''
Query Command
Demonstrates how to write an executable and queryable command.
This will query a channel value on the selected items,
inputting a value will update the channel and querying the
value will show the current value of the channel. The command
@mattcox
mattcox / notifier_cmd.py
Last active June 17, 2018 20:48
Demonstrates how to write an executable and queryable command. The difference is that this command will listen for state changes in a scene. If the selection changes, then the command will check its enable/disable state and force any form it's embedded into to update.
#python
'''
Notifier Command
Demonstrates how to write an executable and queryable command.
The difference is that this command will listen for state changes
in a scene. If the selection changes, then the command will check
its enable/disable state and force any form it's embedded into
@mattcox
mattcox / getImageMaps.py
Last active August 29, 2015 13:57
Get all maps associated with a clip.
import lx
import lxu.select
def GetImageMaps (self, clip_obj, getIdents=True):
images = []
if clip == None:
return []
@mattcox
mattcox / stringPackage.py
Last active June 22, 2017 17:51
This python plugin example defines a new package that can be added to an existing item, adding a string channel called "customData".
#python
'''
This plugin example adds a new package that can be added to
an existing item, adding a float channel called "customData".
Essentially, it's just implementing a custom item. But by not
specifying a supertype, it becomes a generic item that can be
added to an existing item to extend their functionality.
'''
@mattcox
mattcox / packageTest.py
Last active June 22, 2017 17:46
Packages are features that can be added to a modo item to add channels and extend functionality. This may be to override drawing, add extra transforms, or provide some complex functionality that was beyond the capabilities of the original item. This sample demonstrates testing an item to see which packages it has.
import lx
hstSvc = lx.service.Host ()
hstSvc.SpawnForTagsOnly ()
allPackages = []
containsPackages = []
for i in range (hstSvc.NumServers (lx.symbol.a_PACKAGE)):
factory = hstSvc.ServerByIndex (lx.symbol.a_PACKAGE, i)
@mattcox
mattcox / modifierSample.cpp
Last active July 12, 2018 21:10
This sample plugin demonstrates how to create a very simple and pointless modifier. The modifier attaches to every light in the scene and sets the light radiance value to the distance from the center of the world.
/*
*
* modifierSample.cpp
*
* This sample plugin demonstrates how to create a very simple and pointless
* modifier. The modifier attaches to every light in the scene and sets the
* light radiance value to the distance from the center of the world.
*
*/
@mattcox
mattcox / getInstance.cpp
Last active July 12, 2018 21:10
Demonstrates how to get a PackageInstance from a ILxItem COM interface. If you pass this function an item, it will return the class that it derives from, as long as it is one of your classes. Obviously, change the class name to whatever your class is called, as well as the server name!
Instance *
getInstance (
ILxUnknownID item)
{
CLxLoc_PackageInstance pkgInstance (item);
CLxSpawner <Instance> spawn ("myInstance");
if (pkgInstance.test ())
return spawn.Cast (pkgInstance);
@mattcox
mattcox / notifier.py
Created October 21, 2015 16:07
A pointless command that demonstrates how to use a notifier without arguments
#!/usr/bin/env python
import lx
import lxu.command
import modo
class Command (lxu.command.BasicCommand):
def __init__ (self):
lxu.command.BasicCommand.__init__ (self)