Skip to content

Instantly share code, notes, and snippets.

@Farfarer
Farfarer / swizzleRGBA.py
Last active July 15, 2019 10:08
Command to swizzle RGBA vertex map components.
#!/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 / selectSymmetrical.py
Last active February 22, 2019 09:44
Selects elements that are symmetrical to the current selection.
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class GetSymmetricalVertex(lxifc.Visitor):
def __init__(self, accessor):
self.accessor = accessor
self.sym_ids = set()
@Farfarer
Farfarer / selectSchematicNodes.py
Created November 26, 2018 18:14
Selects the schematic nodes of the current item selection. Install to <scripts dir>/lxserv and run the command ffr.selectSchmNodes
#!/usr/bin/env python
import lx
import lxu.select
import lxu.command
class SelectSchmNodes_Cmd(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__(self)
@Farfarer
Farfarer / resetMeshTransform.py
Created August 22, 2018 18:45
Stick this in `<user scripts folder>/lxserv` and restart Modo. You can run the command `ffr.resetMeshTransform` to reset the transforms for selected items and the normals/tangents should be transformed appropriately, too.
#!/usr/bin/env python
import lx
import lxu
import lxifc
import lxu.command
class ListVMaps(lxifc.Visitor):
def __init__(self, meshmap):
self.meshmap = meshmap
@Farfarer
Farfarer / selectGroundPolys.py
Last active August 23, 2018 00:48
Selects all polygons which face straight up and are at or below 0 in the Y axis.
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class SelectGround(lxifc.Visitor):
def __init__(self, poly, mesh):
self.poly = poly
self.mesh = mesh
@Farfarer
Farfarer / randomRGBA.py
Last active August 23, 2018 01:05
Sets the vertex colour of each mesh island to a random value.
#!/usr/bin/env python
import random
import lx
import lxifc
import lxu.command
class SetMarksVisitor (lxifc.Visitor):
def __init__ (self, elem, marks):
self.elem = elem
@Farfarer
Farfarer / listTextureEffects.py
Last active June 13, 2018 11:09
List avaialble texture effects (internal names and user-friendly names) in Modo.
def ListTextureEffects(category=lx.symbol.sSHADE_SURFACE):
internal = []
user = []
host_svc = lx.service.Host()
msg_svc = lx.service.Message ()
msg = lx.object.Message (msg_svc.Allocate ())
for i in xrange(host_svc.NumServers(lx.symbol.a_TEXTUREEFFECT)):
@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)
@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 / 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