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 / queryComponentMode.cpp
Created Mar 18, 2020
Test current component mode using MODO SDK. Posted by Ben Halling on MODO's #coding slack channel.
View queryComponentMode.cpp
LXtID4 currentTypes[4];
LXtID4 vertex_type = srv_sel.LookupType(LXsSELTYP_VERTEX);
LXtID4 edge_type = srv_sel.LookupType(LXsSELTYP_EDGE);
LXtID4 poly_type = srv_sel.LookupType(LXsSELTYP_POLYGON);
LXtID4 item_type = srv_sel.LookupType(LXsSELTYP_ITEM);
currentTypes[0] = vertex_type;
currentTypes[1] = edge_type;
currentTypes[2] = poly_type;
currentTypes[3] = item_type;
LXtID4 cur = srv_sel.CurrentType(currentTypes);
lukpazera / toolHandle.cpp
Created Mar 18, 2020
Tool with handle example. Lifted from sample code posted by Mario Baldi on MODO's #coding Slack channel. I have not tested this code, saving for future reference.
View toolHandle.cpp
#include <lx_tool.hpp>
#include <lx_toolui.hpp>
#include <lx_vmodel.hpp>
#include <lx_vector.hpp>
#include <lxu_attributes.hpp>
#include <lx_plugin.hpp>
#include <lx_layer.hpp>
#include <lx_mesh.hpp>
#include <lx_log.hpp>
lukpazera / toolPixelDraw.cpp
Created Mar 18, 2020
Tool implementation - drawing in screen space. Lifted from MODO's #coding channel on Slack.
View toolPixelDraw.cpp
You return LXfTMOD_DRAW_PIXEL from your ToolModel::Flags method.
Then you'll be called for drawing into screen space.
If you support multiple drawing modes; 3D and screen space,
you can test in your Draw callback by calling ILxView::Flags,
and testing the return type for LXiVIEWv_PIXEL.
You can query the StrokeDraw object passed to your draw method for an ILxView.
When you're in your drawing call, you can call ILxView::Dimensions to get the size of the viewport
to calculate the position to draw.
lukpazera / mouseProximity.cpp
Last active Feb 20, 2020
A WIP sample on how to measure the distance from a given object in viewport to mouse - in pixels.
View mouseProximity.cpp
// This is not entirely working as it crashes MODO when an item with this drawing
// is selected and transform tool is enable. So something somewhere has to return bad value at some point
// and this sample is not handling that.
// This code needs to be executed from within item's Draw method.
// Drawing is aborted if mouse pointer is more then 120 pixels from the item to be drawn.
// The idea is to only draw the item when mouse pointer is close enough to it.
#include <lx_vp.hpp>
CLxUser_View view(stroke);
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;
You can’t perform that action at this time.