Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / 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_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 / 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 / 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 / getReferenceScenesAndItems.py
Created July 24, 2018 11:57
Collect reference items in the selected scene.
import lxu.select
class ReferencedItems:
def __init__(self, scene):
self.mScene = lx.object.Scene(scene)
self.mSceneFilename = self.mScene.Filename()
self.mItems = []
def AddItem(self, item):
print item
@mattcox
mattcox / previewSocketExample.py
Created August 13, 2018 13:43
This sample script demonstrates the basics for connecting to the preview socket, setting the resolution, and the pixel format, and reading back a floating point buffer of the image.
'''
This sample script demonstrates the basics for connecting to the preview
socket, setting the resolution, and the pixel format, and reading back a
floating point buffer of the image.
To test it, launch modo, and execute the command:
telnet.listen port:5678 raw:true
Then run the following in an external Python client.
'''
@mattcox
mattcox / printMeshTags.py
Last active October 4, 2018 14:56
This sample code demonstrates how to enumerate over all polygons on the active mesh layer, and print the material tag assigned to each polygon to the event log.
#python
'''
This sample code demonstrates how to enumerate over all polygons on the active
mesh layer, and print the material tag assigned to each polygon to the event
log.
'''
import lx
import lxu.command
@mattcox
mattcox / kitDumpCommand.py
Created February 14, 2019 16:39
Demonstrates how to list the kits installed in Modo, and query the version numbers. This mostly is a wrapper for the kit.version command.
#python
'''
Demonstrates how to list the kits installed in Modo, and query the version
numbers. This mostly is a wrapper for the kit.version command.
'''
import lx