Skip to content

Instantly share code, notes, and snippets.

@csprance
Last active October 20, 2017 19:26
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 csprance/c950536af6ab8b2ac0ecd419c4e0cb2a to your computer and use it in GitHub Desktop.
Save csprance/c950536af6ab8b2ac0ecd419c4e0cb2a to your computer and use it in GitHub Desktop.
Modo Script to write a bunch of letters
http://www.csprance.com/shots/letters_master.lxo
#!/usr/bin/python
import lx
import sys
######################################
# figure out the text we are going to write ERROR HANDLING DONE HERE FOR INPUT!!!!
def grabInput():
#first we have to create our temp variable that modo uses we set it momentary
lx.eval('user.defNew name string momentary')
#this gives us our dialog box
lx.eval('user.value name')
#we set the value of the user entered info to test
#return our lowercased version
return lx.eval('user.value name ?').lower()
# create the new mesh Item and name it set it as the active selection
def createItem():
# grab our input
text = grabInput()
#create a new layer
lx.eval('layer.new')
#name the layer the user input
lx.eval('item.name {%s} xfrmcore' % text)
# loop through our text and do the things to the letters
# idx = index, x = letter, text = the mesh
for idx , x in enumerate(text):
if ' ' in x:
pass
else:
selCopyPaste(x, text, idx)
#lets just do a little bit of cleanup here and merge all of our verts together
#select all of the polygons
lx.eval('select.all')
#run mesh cleanup on the selected polygons
lx.eval('mesh.cleanup true')
# select and copy our polygon item then return to original item and selCopyPast
# args (letter = letter to select, mesh = name of mesh item, index = position of the current letter [1 based])
def selCopyPaste(letter, mesh, index):
index = -200 * index
#reset our selection
lx.eval('select.drop item')
#select our letter
lx.eval('select.subItem {%s}' % letter)
#select the polygon
lx.eval('select.type polygon')
#select all polyongs
lx.eval('select.all')
#copy all the polygons
lx.eval('copy')
#select the main mesh
lx.eval('select.drop item')
lx.eval('select.subItem {%s}' % mesh)
#set it to polygon mode
lx.eval('select.type polygon')
#hide everything
lx.eval('hide.sel')
#paste in our polygon
lx.eval('paste')
#select all of our polygons
lx.eval('select.all')
#unhide all the rest of our polygons
lx.eval('unhide')
#move our selected polygons -200 * the letters position in the stack
lx.eval('tool.set TransformMove on')
lx.eval('tool.setAttr xfrm.transform TX {%s}' % index )
# apply the tool properties
lx.eval('tool.doApply')
###############################
#Main code execution area#
###############################
# call create item which is the function that kicks everything off and calls the other functions in order
createItem()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment