Skip to content

Instantly share code, notes, and snippets.

@Farfarer
Created April 24, 2017 11:18
Show Gist options
  • Save Farfarer/ec0dbce5688e6fcd2cb91ac1fb7d03ca to your computer and use it in GitHub Desktop.
Save Farfarer/ec0dbce5688e6fcd2cb91ac1fb7d03ca to your computer and use it in GitHub Desktop.
Little MODO utility script for looking up symbol defines by value.
#python
import lx
import lx.symbol as symbols
# Save this into your MODO scripts directory.
# Example usage:
# Find symbols with value of enable
# import symbolUtils as su
# su.find('enable', printOut=True)
# Find symbols with value containing enable
# import symbolUtils as su
# su.contains('enable', printOut=True)
# Find symbols containing ENABLE
# import symbolUtils as su
# su.findSymbols('ENABLE', printOut=True)
def find(value, ignoreCase=False, printOut=False, withlxsymbol=False):
res = []
if ignoreCase:
res = [x for x in dir(symbols) if value.lower() == getattr(symbols, x).lower()]
else:
res = [x for x in dir(symbols) if value == getattr(symbols, x)]
if printOut:
printList(res, withlxsymbol)
return res
def contains(value, ignoreCase=False, printOut=False, withlxsymbol=False):
res = []
if ignoreCase:
res = [x for x in dir(symbols) if value.lower() in getattr(symbols, x).lower()]
else:
res = [x for x in dir(symbols) if value in getattr(symbols, x)]
if printOut:
printList(res, withlxsymbol)
return res
def findSymbols(value, ignoreCase=False, printOut=False, withlxsymbol=False):
res = []
if ignoreCase:
res = [x for x in dir(symbols) if value.lower() in x.lower()]
else:
res = [x for x in dir(symbols) if value in x]
if printOut:
printList(res, withlxsymbol)
return res
def printList(entries, withlxsymbol=False):
if withlxsymbol:
print '\nlx.symbol.'.join(entries)
else:
print '\n'.join(entries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment