Last active
June 22, 2017 17:46
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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