Skip to content

Instantly share code, notes, and snippets.

@mattcox
Last active June 22, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattcox/84ecd1e71d2a2995ad1b to your computer and use it in GitHub Desktop.
Save mattcox/84ecd1e71d2a2995ad1b to your computer and use it in GitHub Desktop.
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)
try:
factory.InfoTag (lx.symbol.sPKG_SUPERTYPE)
continue
except:
'''
We rely on the fact that this will fail if the super type
is undefined. If it is, the package is a true Package that
can be added to items, so we catch the error and add it to
the list.
'''
allPackages.append (factory.Name ())
for package in allPackages:
if item.PackageTest (package) == True:
containsPackages.append (package)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment