Skip to content

Instantly share code, notes, and snippets.

@mattcox
mattcox / continueOnFunctionMiss.py
Created July 21, 2017 22:56
This script when attached to a breakpoint will continue lldb if the provided function doesn't appear in the current backtrace.
#!/usr/bin/env python
'''
This script when attached to a breakpoint will continue lldb if the provided
function doesn't appear in the current backtrace.
To use this script, add a file called .lldbinit to your home directory,
with the following line:
@mattcox
mattcox / EvaluateParticles.cpp
Created November 20, 2017 19:40
This demonstrates how to evaluate a particle source for it's particles. By default, only position, transform and ID are evaluated, however it could easily be extended to support other types.
/*
* This demonstrates how to evaluate a particle source for it's particles.
* By default, only position, transform and ID are evaluated, however it
* could easily be extended to support other types.
*
* To evaluate particles, you must provide a TriangleSoup to the Tableau,
* allowing it populate your soup with the particle data. This is very
* similar to reading surfaces, but we only care about vertex data, not
* polygons.
*
@mattcox
mattcox / notifier_cmd.py
Last active June 17, 2018 20:48
Demonstrates how to write an executable and queryable command. The difference is that this command will listen for state changes in a scene. If the selection changes, then the command will check its enable/disable state and force any form it's embedded into to update.
#python
'''
Notifier Command
Demonstrates how to write an executable and queryable command.
The difference is that this command will listen for state changes
in a scene. If the selection changes, then the command will check
its enable/disable state and force any form it's embedded into
@mattcox
mattcox / Manual_ToolOperation_Example.cpp
Last active July 12, 2018 21:08
This example demonstrates how to manually implement a tool operation item.
/*
*
* This example demonstrates how to manually implement a tool operation
* item.
*
*/
#include <lxsdk/lx_mesh.hpp>
#include <lxsdk/lx_tool.hpp>
#include <lxsdk/lx_toolui.hpp>
#include <lxsdk/lx_vector.hpp>
@mattcox
mattcox / pmodel_createPlane_simple.cpp
Last active July 12, 2018 21:09
Demonstrates a simple plane mesh operation for the Modo procedural modelling system.
#include <lxsdk/lx_mesh.hpp>
#include <lxsdk/lx_pmodel.hpp>
#include <lxsdk/lx_seltypes.hpp>
#include <lxsdk/lxu_attributes.hpp>
#define SERVER_NAME "pmodel.createPlane"
#define ATTRs_SIZE "size"
#define ATTRi_SIZE 0
class MeshOp :
@mattcox
mattcox / notifier.py
Created October 21, 2015 16:07
A pointless command that demonstrates how to use a notifier without arguments
#!/usr/bin/env python
import lx
import lxu.command
import modo
class Command (lxu.command.BasicCommand):
def __init__ (self):
lxu.command.BasicCommand.__init__ (self)
@mattcox
mattcox / getInstance.cpp
Last active July 12, 2018 21:10
Demonstrates how to get a PackageInstance from a ILxItem COM interface. If you pass this function an item, it will return the class that it derives from, as long as it is one of your classes. Obviously, change the class name to whatever your class is called, as well as the server name!
Instance *
getInstance (
ILxUnknownID item)
{
CLxLoc_PackageInstance pkgInstance (item);
CLxSpawner <Instance> spawn ("myInstance");
if (pkgInstance.test ())
return spawn.Cast (pkgInstance);
@mattcox
mattcox / modifierSample.cpp
Last active July 12, 2018 21:10
This sample plugin demonstrates how to create a very simple and pointless modifier. The modifier attaches to every light in the scene and sets the light radiance value to the distance from the center of the world.
/*
*
* modifierSample.cpp
*
* This sample plugin demonstrates how to create a very simple and pointless
* modifier. The modifier attaches to every light in the scene and sets the
* light radiance value to the distance from the center of the world.
*
*/
@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 / eval_matrixChannel.cpp
Last active July 12, 2018 21:12
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…
/*
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.
*/