Skip to content

Instantly share code, notes, and snippets.

@mattcox
mattcox / pmodel_selectOdd.cpp
Last active August 26, 2021 14:27
Example of a simple selection operation for the Modo procedural modelling system that selects every other polygon. It demonstrates how to use thread slots, to allow selection to be evaluated from multiple threads
#include <lxsdk/lx_mesh.hpp>
#include <lxsdk/lx_pmodel.hpp>
#include <lxsdk/lx_seltypes.hpp>
#include <lxsdk/lx_thread.hpp>
#include <lxsdk/lxu_attributes.hpp>
#define SERVER_NAME "pmodel.selectEveryOther"
/*
* The Selection Operation is evaluated in parallel from multiple threads. As
@mattcox
mattcox / pmodel_createPlane_incremental.cpp
Last active July 30, 2022 20:27
Demonstrates a simple plane mesh operation for the Modo procedural modelling system. This demonstrates how to do incremental updates that create the polygon on the first evaluation, and then updates point positions on subsequent evaluations. Incremental updates can significantly improve performance, as Modo will only rebuild the surface for draw…
#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 / 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 / packageTest.py
Last active June 22, 2017 17:46
Packages are features that can be added to a modo item to add channels and extend functionality. This may be to override drawing, add extra transforms, or provide some complex functionality that was beyond the capabilities of the original item. This sample demonstrates testing an item to see which packages it has.
import lx
hstSvc = lx.service.Host ()
hstSvc.SpawnForTagsOnly ()
allPackages = []
containsPackages = []
for i in range (hstSvc.NumServers (lx.symbol.a_PACKAGE)):
factory = hstSvc.ServerByIndex (lx.symbol.a_PACKAGE, i)
@mattcox
mattcox / stringPackage.py
Last active June 22, 2017 17:51
This python plugin example defines a new package that can be added to an existing item, adding a string channel called "customData".
#python
'''
This plugin example adds a new package that can be added to
an existing item, adding a float channel called "customData".
Essentially, it's just implementing a custom item. But by not
specifying a supertype, it becomes a generic item that can be
added to an existing item to extend their functionality.
'''
@mattcox
mattcox / getImageMaps.py
Last active August 29, 2015 13:57
Get all maps associated with a clip.
import lx
import lxu.select
def GetImageMaps (self, clip_obj, getIdents=True):
images = []
if clip == None:
return []
@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