Skip to content

Instantly share code, notes, and snippets.

@mattcox
mattcox / query_cmd.py
Last active December 30, 2015 08:39
Demonstrates how to write an executable and queryable command. This will query a channel value on the first selected item, inputting a value will update the channel and querying the value will show the current value of the channel. The command will only be enabled if an item is selected, if there is no selection, then the command will be disabled.
#python
'''
Query Command
Demonstrates how to write an executable and queryable command.
This will query a channel value on the selected items,
inputting a value will update the channel and querying the
value will show the current value of the channel. The command
@mattcox
mattcox / helloWorld_cmd.py
Last active December 30, 2015 08:39
"Hello World!" - Demonstrates the very basics needed for a command. This will print "Hello World!" to the event log. The command will only be enabled if an item is selected, if there is no selection, then the command will be disabled.
#python
'''
Hello World!
This example demonstrates the very basics needed for a command. Firing
the command prints "Hello World!" to the event log. The command includes
enable and disable states, controlled by the selection. If an item
is selected, the command will be enabled, if not, it won't be.
#!/usr/bin/env python
'''
This sample Python plugin demonstrates how to use notifiers in Python.
To use, embed the command in a form and change item selection, the command
should update.
'''
@mattcox
mattcox / list_files.py
Created September 17, 2013 19:57
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.
#!/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
@mattcox
mattcox / GetInfluences.py
Created August 15, 2013 16:48
Return a list of influences connected to the an effector.
import lx
import lxu.select
def GetInfluences (effector):
'''
Takes an effector input and returns a list of all
connected influence items.
'''
influences = []
@mattcox
mattcox / material_new.py
Last active November 9, 2021 08:19
Auto generates material masks for every new, unique material ptag in the scene.
#!/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 / commandDemo.cpp
Last active July 12, 2018 21:11
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.
#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 / shapeDraw.py
Last active April 16, 2020 08:08
Python example demonstrating how to modify GL drawing of an item.
#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 / Group.py
Last active June 22, 2017 18:07
Utility functions for manipulating groups inside of Modo.
#python
'''
Class and functions for working with groups inside of modo.
'''
import lx
class Group:
def __init__ (self, group):
@mattcox
mattcox / SurfaceForce.py
Last active December 16, 2021 14:48
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.
#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