Skip to content

Instantly share code, notes, and snippets.

@Farfarer
Farfarer / averageRGBA.py
Created February 6, 2017 17:38
Average the selected RGBA vertex maps across each selected polygon.
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class ListMaps (lxifc.Visitor):
def __init__ (self, meshmap):
self.meshmap = meshmap
self.mapIDs = []
@Farfarer
Farfarer / removeSchematicNodesPYAPI.py
Created February 28, 2017 16:32
Ways to remove ALL schematic nodes via the pyAPI and TD SDK in MODO.
#pyAPI version
scene_svc = lx.service.Scene ()
scene = lxu.select.SceneSelection().current()
graph = lx.object.ItemGraph (scene.GraphLookup ('schmItem'))
itemsToRemove = set()
for t in xrange(scene_svc.ItemTypeCount()):
type = scene_svc.ItemTypeByIndex(t)
@Farfarer
Farfarer / selectItemCenter.py
Last active March 1, 2017 10:59
Snippet for selecting item centers using the pyAPI in MODO.
def selectItemCenter (item, dropSelection=True):
sel_svc = lxu.service.Selection()
# Find the internal code for "center" selection type.
sel_type_center = sel_svc.LookupType (lx.symbol.sSELTYP_CENTER)
# Set up a selection packet translator for "center" selections.
# This lets us bundle up centers into selection "packets" for passing on to the selection service.
# Or read information about existing selection "packets" that we get from the selection service.
center_pkt_trans = lx.object.CenterPacketTranslation (sel_svc.Allocate (lx.symbol.sSELTYP_CENTER))
@Farfarer
Farfarer / symbolUtils.py
Created April 24, 2017 11:18
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
@Farfarer
Farfarer / listGraphConnections.py
Created May 8, 2017 16:23
A MODO script to lists all connections on all graphs for the selected items and their channels.
#!/usr/bin/env python
import lx
import lxu.select
cui_svc = lx.service.ChannelUI ()
graphNames = []
scene = lxu.select.SceneSelection().current()
for x in range(scene.GraphCount()):
@Farfarer
Farfarer / renamePTag.py
Last active May 24, 2017 10:09
MODO plugin for renaming polygon tags.
#!/usr/bin/env python
import lx
import lxu
import lxifc
import lxu.command
class MeshPicker (lxu.command.BasicHints):
def __init__ (self):
scn_svc = lx.service.Scene ()
@Farfarer
Farfarer / newClipCustomSize.py
Created August 25, 2017 11:21
Adds a new command for Modo, clip.newWithSize, which lets you specify explicit width/height of newly created images, rather than the usual square power-of-two.
#!/usr/bin/env python
import os
import lx
import modo
import lxifc
import lxu.select
import lxu.command
@Farfarer
Farfarer / selectByColor.py
Created October 30, 2017 11:48
Select vertices by vertex color.
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class SelectByColor_Vis(lxifc.Visitor):
def __init__(self, mesh, point, vmapID, rgb, selMode, sel_svc, vtx_pkt_trans, sel_type_vert):
self.mesh = mesh
self.point = point
@Farfarer
Farfarer / islandCount.py
Created January 2, 2018 19:34
Command to tell you the number of polygon islands in the active mesh(es). Queryable in script via islandCount = lx.eval1('ffr.islandCount ?')
#!/usr/bin/env python
import lx
import lxu.command
import lxifc
class SetMarks (lxifc.Visitor):
def __init__ (self, acc, mark):
self.acc = acc
self.mark = mark
@Farfarer
Farfarer / quantize.py
Last active March 12, 2019 13:10
Wrapper command for vertMap.quantize so you can type in the number of divisions, rather than calculate them manually.
#!/usr/bin/env python
import lx
import lxu.command
class Quantize_Cmd(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__(self)
self.dyna_Add ('steps', lx.symbol.sTYPE_INTEGER)