Skip to content

Instantly share code, notes, and snippets.

@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 / IsItAMask.py
Last active Dec 17, 2015
IsItAMask - Modo Python API example to show if the selected item is a texture layer mask or not.
View IsItAMask.py
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 Aug 15, 2013
Return a list of influences connected to the an effector.
View GetInfluences.py
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 Sep 17, 2013
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.
View list_files.py
#!/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
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 / 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 / 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 / Group.py
Last active Jun 22, 2017
Utility functions for manipulating groups inside of Modo.
View Group.py
#python
'''
Class and functions for working with groups inside of modo.
'''
import lx
class Group:
def __init__ (self, group):