Skip to content

Instantly share code, notes, and snippets.

View lukpazera's full-sized avatar

Lukasz Pazera lukpazera

View GitHub Profile
@lukpazera
lukpazera / toolInput.cpp
Created June 10, 2019 08:34
A method to track input for tool events, thought it might be useful to others.
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
lukpazera / meshListen.py
Created June 10, 2019 08:32
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
lukpazera / mergeTransforms.py
Last active April 10, 2019 09:35
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
lukpazera / constraintRotOffset.py
Created April 3, 2019 10:24
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
lukpazera / ItemPackageFormFilter.CFG
Created December 12, 2018 11:31
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.
<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>
</hash>
</atom>
@lukpazera
lukpazera / ArgumentNotifier.py
Created December 12, 2018 11:29
An example of setting up a notifier for command argument in MODO SDK. Snatched from post by James O'Hare on MODO slack coding channel.
class Notifier(lxifc.UIValueHints):
def __init__(self):
self._notifiers = [('channel.value', '+v channelName itemType'),]
def uiv_NotifierCount(self):
return len(self._notifiers)
def uiv_NotifierByIndex(self, index):
return self._notifiers[index]
@lukpazera
lukpazera / layoutWindowConfigExample.CFG
Created November 24, 2018 13:27
How to define layout in MODO config so it's available by key to the layout.window command. Snatched from Funk example on MODO slack channel.
<atom type="Frame">
<hash type="Layout" key="base.mbUVSingle_Layout" val="viewportGroup">
<atom type="IdealSize">1323 875</atom>
<list type="Port">UVmodel 0 1 0 1 TemplateUV_View</list>
<atom type="SwitcherClass">normal</atom>
<atom type="UserName">Mario UV</atom>
</hash>
<hash type="LayoutWindow" key="mbUvWindow">
<atom type="Title">Mario UV</atom>
@lukpazera
lukpazera / cmdTextValueHint.py
Created September 7, 2018 11:21
This command shows how to set up text hints for an integer command argument in python. Courtesy of James O'Hare.
#python
import lx
import lxu.command
my_hint = ( (0, 'zero' ),
(1, 'one' ),
(-1, 'minusone' ),)
class TextValueHint_Cmd(lxu.command.BasicCommand):
@lukpazera
lukpazera / printChannelPackages.py
Created August 29, 2018 09:39
Script that prints out channel package for each channel of the first selected item.
import modo
item = modo.Scene().selected[0]
chanCount = item.internalItem.ChannelCount()
chanList = []
for i in xrange(chanCount - 1, -1, -1):
try:
package = item.internalItem.ChannelPackage(i)
except LookupError:
lx.out(item.internalItem.ChannelName(i))
@lukpazera
lukpazera / wxfrmInvert.cpp
Last active February 15, 2016 13:42
Two ways to get item's inverted world transform matrix.
/*
* This snippet demonstrates two of the ways to obtain item's inverted world transform matrix.
*/
// --- METHOD 1
CLxUser_Scene scene;
item.Context (scene);
CLxUser_ChannelRead chanRead;
CLxUser_SelectionService selSvc;