Skip to content

Instantly share code, notes, and snippets.

@mattcox
mattcox / eval_matrixChannel.cpp
Last active Jul 12, 2018
This snippet is to demonstrate how to write to a matrix channel in modo from an eval modifier. This is the correct way to write to a matrix. This does assume that you have set the matrix channel you want to drive as a channel for the modifier, using eval.AddChan(item_loc, LXsICHAN_XFRMCORE_WPOSMATRIX, LXfECHAN_WRITE); in your modifier constructo…
View eval_matrixChannel.cpp
/*
This snippet is to demonstrate how to write to a matrix channel
in modo from an eval modifier. This is the correct way to write
to a matrix. This does assume that you have set the matrix channel
you want to drive as a channel for the modifier, using something like:
eval.AddChan(item_loc, LXsICHAN_XFRMCORE_WPOSMATRIX, LXfECHAN_WRITE);
in your modifier constructor. This method will drive the matrix
channel directly, so instead of using the local channels to calculate
the world SRT, it'll use the values the modifier provides it with.
*/
@mattcox
mattcox / matchXfrm.cpp
Last active Jul 12, 2018
Match Transform Command for Luxology Modo.
View matchXfrm.cpp
/*
matchXfrm.cpp
Sample plugin to demonstrate a simple command that matches
position, rotation and scale between multiple selected items.
This command operates slightly differently to the built in
match.position, rotation, scale commands. The built in commands
will average out the transform if multiple items are selected,
@mattcox
mattcox / IsItAMask.py
Last active Dec 17, 2015
IsItAMask - Modo Python API example to show if the selected item is a texture layer mask or not.
View IsItAMask.py
import lx
import lxu.select
scn_svc = lx.service.Scene()
def IsItAMask(item):
if scn_svc.ItemTypeName(scn_svc.ItemTypeSuper(item.Type())) == lx.symbol.sITYPE_TEXTURELAYER:
scene = item.Context()
graph = lx.object.ItemGraph(scene.GraphLookup(lx.symbol.sGRAPH_SHADELOC))
if graph.RevCount(item) > 0:
@mattcox
mattcox / SurfaceForce.py
Last active Jun 16, 2021
This example plugin for modo 701, shows how to create a surface force in Python. The force will read a mesh, get the closest position on that mesh and find the normal at that position. A force will be created along the normal vector of the surface. The result is a force that pushes particles and dynamic objects away from the surface.
View SurfaceForce.py
#python
'''
Surface Force
This example plugin for modo 701, shows how to create a surface force in
Python. The force will read a mesh, get the closest position on that mesh
and find the normal at that position. A force will be created along the
normal vector of the surface. The result is a force that pushes particles
@mattcox
mattcox / Group.py
Last active Jun 22, 2017
Utility functions for manipulating groups inside of Modo.
View Group.py
#python
'''
Class and functions for working with groups inside of modo.
'''
import lx
class Group:
def __init__ (self, group):
@mattcox
mattcox / shapeDraw.py
Last active Apr 16, 2020
Python example demonstrating how to modify GL drawing of an item.
View shapeDraw.py
#python
'''
Shape Draw python example. This python plugins demonstrates how to create
a Package that can be added to existing items, that controls how they draw
in the GL viewport. We will simply draw a circle. A radius channel and an
sides channel will control how the circle is drawn.
To use, add the python script to an lxserv folder in your scripts directory.
Select an locator item and enter: item.addPackage shape.draw. To remove the
@mattcox
mattcox / commandDemo.cpp
Last active Jul 12, 2018
Demonstrates how to spawn another command from a command plugin. This will create a new command with a single argument called "mask", the mask argument will be passed to the material.new command to create a new material mask.This should only be used in the context of a command plugin.
View commandDemo.cpp
#include <lx_plugin.hpp>
#include <lxu_command.hpp>
/*
* The server name is the name of the command that is used to run the command
* in modo. The argument name is the name of the argument that will define the
* material mask.
*/
#define SERVER_NAME "command.demo"
@mattcox
mattcox / material_new.py
Last active Aug 19, 2017
Auto generates material masks for every new, unique material ptag in the scene.
View material_new.py
#!/usr/bin/env python
'''
Auto generates material masks for every material ptag in the scene.
Usage: Put the script in a folder called lxserv inside your modo scripts
folder. Restart modo. Run the command: material.generate
'''
import lx
@mattcox
mattcox / GetInfluences.py
Created Aug 15, 2013
Return a list of influences connected to the an effector.
View GetInfluences.py
import lx
import lxu.select
def GetInfluences (effector):
'''
Takes an effector input and returns a list of all
connected influence items.
'''
influences = []
@mattcox
mattcox / list_files.py
Created Sep 17, 2013
Demonstrates how to setup a simple popup menu populated using dynamic values. This will search a directory for files and list all of the files inside the popup.
View list_files.py
#!/usr/bin/env python
'''
Demonstrates how to setup a simple popup menu populated using dynamic values.
This will search a directory for files and list all of the files inside the
popup.
As notifiers are currently unsupported in modo 701 SP2, we can't force the
popup to update when the directory contents changes. So for now, it'll only