Skip to content

Instantly share code, notes, and snippets.

View notifier_sample.py
#!/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 Dec 30, 2015
"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.
View helloWorld_cmd.py
#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 Dec 30, 2015
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.
View query_cmd.py
#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 Jun 17, 2018
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.
View notifier_cmd.py
#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 Aug 29, 2015
Get all maps associated with a clip.
View getImageMaps.py
import lx
import lxu.select
def GetImageMaps (self, clip_obj, getIdents=True):
images = []
if clip == None:
return []
@mattcox
mattcox / stringPackage.py
Last active Jun 22, 2017
This python plugin example defines a new package that can be added to an existing item, adding a string channel called "customData".
View stringPackage.py
#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 Jun 22, 2017
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.
View packageTest.py
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 Jul 12, 2018
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.
View modifierSample.cpp
/*
*
* 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 Jul 12, 2018
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!
View getInstance.cpp
Instance *
getInstance (
ILxUnknownID item)
{
CLxLoc_PackageInstance pkgInstance (item);
CLxSpawner <Instance> spawn ("myInstance");
if (pkgInstance.test ())
return spawn.Cast (pkgInstance);
@mattcox
mattcox / notifier.py
Created Oct 21, 2015
A pointless command that demonstrates how to use a notifier without arguments
View notifier.py
#!/usr/bin/env python
import lx
import lxu.command
import modo
class Command (lxu.command.BasicCommand):
def __init__ (self):
lxu.command.BasicCommand.__init__ (self)