Skip to content

Instantly share code, notes, and snippets.

Lukasz Pazera lukpazera

Block or report user

Report or block lukpazera

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lukpazera /
Created Aug 21, 2019
This is how to read evaluated setup channels using MODO python SDK. The crucial bit is using scene.SetupChannels() in line 11. Stolen from Foundry's coding slack channel.
scene_svc = lx.service.Scene()
sel_svc = lx.service.Selection()
pkt_trans = lx.object.ItemPacketTranslation(sel_svc.Allocate(lx.symbol.sSELTYP_ITEM))
sel_type = sel_svc.LookupType(lx.symbol.sSELTYP_ITEM)
for i in xrange(sel_svc.Count(sel_type)):
pkt = sel_svc.ByIndex(sel_type, i)
item = pkt_trans.Item(pkt)
scene = item.Context()
lukpazera /
Last active Jun 23, 2019
Gets mesh and and an index of a polygon that is under the mouse in MODO viewport.
# python
import lx
import modo
# This snippet queries polygon that is under a mouse.
# Querying polygon only works correctly on active meshes.
# That means that if mouse is over the mesh that is not active
# (was not selected prior to entering component mode),
lukpazera / onIdleEvent.cpp
Last active Jun 20, 2019
How to set up on idle event in MODO SDK.
View onIdleEvent.cpp
#include "lx_visitor.hpp"
* OnIdleVisitor is used to perform On Idle Event.
* Evaluate() method will be called once the on idle event is registered.
* If you add more methods to this class and want to access them from outside this is how you need to do it:
* onIdleVisitorInstance.loc.method();
* You get direct access to this class contents via '.loc'.
* Don't ask me why ;).
lukpazera / undoGroup.CFG
Last active Jun 18, 2019
This is piece of MODO config allows for defining a command (my.command) as part of undo group (myUndoGroup). 'undoPlusPrevious' means that when undoing my.command it will do one more undo step automatically. It allows for bundling multiple commands into one undo step.
View undoGroup.CFG
<atom type="CommandUndoGroup">
<hash type="Command" key="my.command">myUndoGroup</hash>
<hash type="GroupBehavior" key="myUndoGroup">undoPlusPrevious</hash>
lukpazera /
Created Jun 17, 2019
This snippet can be used to align vector in world space to a current view. This could be used for something like Align To View in MODO locator shape properties. We could potentially draw a shape that is always facing view.
import lx
import lxu
import modo
scene = modo.Scene()
i = scene.item('Locator')
# Get current MODO viewport interface
vs = lx.service.View3Dport()
currentViewIndex = vs.Current()
lukpazera / toolInput.cpp
Created Jun 10, 2019
A method to track input for tool events, thought it might be useful to others.
View toolInput.cpp
void input_testing(ILxUnknownID vts)
// setup
CLxUser_VectorStack vec(vts);
LXpToolInputEvent *input_event;
input_event = (LXpToolInputEvent *)vec.Read(offset_input);
// Tool Input Count(could be used to track number of clicks etc)
int count = input_event->count;
lukpazera /
Created Jun 10, 2019
Mesh listener setup snippet from Tom Dymond, posted on Foundry coding slack channel.
import modo, lxifc
geo = modo.MeshGeometry("Cube").internalMesh
port = lx.object.ListenerPort(geo)
class mesh_listener(lxifc.MeshListener):
undoService = lx.service.Undo()
def __init__(self):
self.listenerService = lx.service.Listener()
self.COM_object = lx.object.Unknown(port)
lukpazera /
Last active Apr 10, 2019
Using python TDSDK to merge two rotation transform items in MODO. The assumption is that the 2nd item is zero rotation one so effectively this removes zeroed rotation from an item.
import modo
scene = modo.Scene()
i = scene.selected[0]
l = modo.LocatorSuperType(i)
rot = l.rotation
transformsStack = [xfrm for xfrm in l.transforms]
lukpazera /
Created Apr 3, 2019
This gist will calculate rotation offset angle values for a rotation constraint between two items in MODO.
""" This gist will calculate rotation offset angle values for a rotation constraint
between two items in MODO. It'll be exactly the same as setting up the constraint
with compensation turned on.
This code can be useed to update existing rotation constraint setup with new offset
without reapplying the constraint again.
The process is simple.
- get the world rotation matrix of the target and invert it.
- multiply source world rotation matrix by the inverted target matrix.
lukpazera / ItemPackageFormFilter.CFG
Created Dec 12, 2018
This is an example of a MODO config file that sets up a properties form that is only visible for an item that contains a given package. One more snatch from James O'Hare.
View ItemPackageFormFilter.CFG
<atom type="Filters">
<hash type="Preset" key="ffr_morphCage.package:filterPreset">
<atom type="Name">Morph Cage View</atom>
<atom type="Enable">1</atom>
<list type="Node">1 .group 0 &quot;&quot;</list>
<list type="Node">1 packagename ffr_morphCage</list>
<list type="Node">-1 .endgroup </list>
You can’t perform that action at this time.