Skip to content

Instantly share code, notes, and snippets.

View lukpazera's full-sized avatar

Lukasz Pazera lukpazera

View GitHub Profile
@lukpazera
lukpazera / lp_cmdGroupStats.py
Last active December 17, 2015 01:49
A simple modo Python API command that implements group.stats command. The command enumerates all selected groups and returns a number of items and channels in every group.
#python
"""
Group Statistics Command
------------------------
A simple command that enumerates all selected groups
and returns a number of items and channels in every group
Author: Lukasz Pazera
@lukpazera
lukpazera / lp_cmdListXfrm.py
Created May 21, 2013 13:10
Plugin implements item.listXfrm command that lists all selected item's transform items in Event Log.
#python
'''
List Item Transforms
--------------------
Plugin implements item.listXfrm command that lists
all selected item's transforms in Event Log
'''
@lukpazera
lukpazera / lp_cmdListTags.py
Created May 21, 2013 13:59
Implements a simple item.listTags command that lists all string tags attached to the selected item.
#python
"""
List all Item's Tags
--------------------
Simple command that lists all tags attached to the selected item.
The output goes to Event Log.
"""
import lx
@lukpazera
lukpazera / getChannelSelection.py
Last active February 17, 2023 13:15
A simple script for MODO that reads current channel selection from scene and outputs it to Event Log.
# python
""" Get Channel Selection.
There is no utility class for handling channel selection
like there is for items and scenes so it has to be done manually.
"""
import lx
selection_service = lx.service.Selection()
@lukpazera
lukpazera / customItemDraw.py
Last active December 19, 2015 02:49
This sample implements custom item that draws a circle in viewport. Circle's size and axis can be defined using item's custom channels. You can edit these custom channels in channel list (they won't show up in properties).
# python
""" Custom item drawing a shape.
----------------------------
Implements a custom item that draws a simple shape in viewport.
The item is of Locator supertype.
"""
import lx
import lxifc
@lukpazera
lukpazera / cmdMatchXfrm.py
Created July 2, 2013 11:11
This is python translation of Matt Cox's matchXfrm.cpp C++ command and was done as an exercise while learning MODO python API. Matt's original: https://gist.github.com/mattcox/4742206
#python
""" Match Item Transforms.
Command matches transforms of one item to another.
Select 2 or more items and all items will be matched to last selected one.
I'm not author of this command.
This is python translation of Matt Cox's matchXfrm.cpp C++ equivalent
and was done as an exercise while learning MODO python API.
@lukpazera
lukpazera / cmdItemAimAt.py
Last active December 19, 2015 17:49
Implements a simple command that replicates what Direction Constraint does. It allows to aim one item at another using third item as an up vector.
#python
""" Aim Item Command.
Command sets one item (source item) rotation so that it
points at another item (target item) with an upvector defined
by third item (up vector item).
Command essentially replicates what Direction Constraint does.
Only it just applies rotation to the source item only at a current frame and action.
@lukpazera
lukpazera / item_add_name_prefix.py
Last active June 9, 2018 15:58
Very simple script that renames selected items by adding a string prefix to each item's current name.
# python
""" Short snippet demonstrating how you can edit scene item's name using MODO 701 Python API.
"""
import lx
import lxu.select
PREFIX = 'prefix_'
@lukpazera
lukpazera / item_selection_filter.py
Last active March 10, 2021 19:56
Simple example of filtering item selection to group items only.
# python
""" Snippet demonstrates how to filter item selection out so it contains
only items of required type (group items in this case).
Filtered items are printed out in Event Log.
"""
import lx
import lxu.select
@lukpazera
lukpazera / log.py
Last active August 29, 2015 13:58
An example of a simple class that allows for writing messages into desired log.
# python
""" Log allows for writing messages into choosen log subsystem.
Messages can have simple hierarchical format:
- Head Message,
- Child Message 1,
- Child Message 2,
- Child Message 3,
- etc.