Skip to content

Instantly share code, notes, and snippets.

James O'Hare Farfarer

View GitHub Profile
@Farfarer
Farfarer / selectSymmetrical.py
Last active Feb 22, 2019
Selects elements that are symmetrical to the current selection.
View selectSymmetrical.py
#!/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 Nov 26, 2018
Selects the schematic nodes of the current item selection. Install to <scripts dir>/lxserv and run the command ffr.selectSchmNodes
View selectSchematicNodes.py
#!/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 Aug 22, 2018
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.
View resetMeshTransform.py
#!/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 Aug 23, 2018
Selects all polygons which face straight up and are at or below 0 in the Y axis.
View selectGroundPolys.py
#!/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 Aug 23, 2018
Sets the vertex colour of each mesh island to a random value.
View randomRGBA.py
#!/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 Jun 13, 2018
List avaialble texture effects (internal names and user-friendly names) in Modo.
View listTextureEffects.py
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 Mar 12, 2019
Wrapper command for vertMap.quantize so you can type in the number of divisions, rather than calculate them manually.
View quantize.py
#!/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 Jan 2, 2018
Command to tell you the number of polygon islands in the active mesh(es). Queryable in script via islandCount = lx.eval1('ffr.islandCount ?')
View islandCount.py
#!/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 Oct 30, 2017
Select vertices by vertex color.
View selectByColor.py
#!/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 / newClipCustomSize.py
Created Aug 25, 2017
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.
View newClipCustomSize.py
#!/usr/bin/env python
import os
import lx
import modo
import lxifc
import lxu.select
import lxu.command
You can’t perform that action at this time.