Skip to content

Instantly share code, notes, and snippets.

@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 / IsItAMask.py
Last active December 17, 2015 08:59
IsItAMask - Modo Python API example to show if the selected item is a texture layer mask or not.
import lx
import lxu.select
scn_svc = lx.service.Scene()
def IsItAMask(item):
if scn_svc.ItemTypeName(scn_svc.ItemTypeSuper(item.Type())) == lx.symbol.sITYPE_TEXTURELAYER:
scene = item.Context()
graph = lx.object.ItemGraph(scene.GraphLookup(lx.symbol.sGRAPH_SHADELOC))
if graph.RevCount(item) > 0:
@mattcox
mattcox / GetInfluences.py
Created August 15, 2013 16:48
Return a list of influences connected to the an effector.
import lx
import lxu.select
def GetInfluences (effector):
'''
Takes an effector input and returns a list of all
connected influence items.
'''
influences = []
@mattcox
mattcox / list_files.py
Created September 17, 2013 19:57
Demonstrates how to setup a simple popup menu populated using dynamic values. This will search a directory for files and list all of the files inside the popup.
#!/usr/bin/env python
'''
Demonstrates how to setup a simple popup menu populated using dynamic values.
This will search a directory for files and list all of the files inside the
popup.
As notifiers are currently unsupported in modo 701 SP2, we can't force the
popup to update when the directory contents changes. So for now, it'll only
#!/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 / 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 / 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 / Group.py
Last active June 22, 2017 18:07
Utility functions for manipulating groups inside of Modo.
#python
'''
Class and functions for working with groups inside of modo.
'''
import lx
class Group:
def __init__ (self, group):