Skip to content

Instantly share code, notes, and snippets.

@nicelifeBS
nicelifeBS / ListSelSets.py
Created April 1, 2014 23:29
modo - pyAPI test. Returns a list of all selection sets of a selected meshItem. First two methods are old python scripting (the second uses the lx.Service for query). The third method is pyAPI
#!/usr/bin/env python
import time
import lx
import lxu.select
def output(command):
'''introspect methods and classes'''
lx.out('$$$$$$$$$ dir $$$$$$$$')
@nicelifeBS
nicelifeBS / superSpinbox.py
Created November 10, 2014 10:15
PySide QDoubleSpinBox with mathematical operators
class superSpinBox(QDoubleSpinBox):
""""Spinbox which allows math expressions. Requires 'from __future__ import division' """
def __init__(self, parent=None):
QDoubleSpinBox.__init__(self, parent)
def validate(self, text, pos):
return QValidator.Acceptable
def valueFromText(self, text):
@nicelifeBS
nicelifeBS / gist:540e6c1061f8a4c648c2
Created March 15, 2015 08:24
modo pyAPI: Lookup scene types
scene_srv = lx.service.Scene()
scene_srv.ItemTypeLookup(lx.symbol.sITYPE_MESH) # returns integer id of the mesh symbol
# 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
# python
""" Short snippet demonstrating how you can edit scene item's name using MODO 701 Python API.
"""
import lx
import lxu.select
PREFIX = 'prefix_'
@nicelifeBS
nicelifeBS / vector_class.py
Last active October 6, 2015 09:24
Vector class
#python
import math
class vector(object):
"""vector([x,y,z]) -> create a vector object in 3D space."""
def __init__(self, data):
self.data = data
if len(self.data) != 3:
raise ValueError("Expecting a 3D vector -> [x,y,z]")
# python
# modo 901
# Get txtLocator and clipItem of an imageMap
imageMap = modo.Item('imageMap028')
shaderGraph = lx.object.ItemGraph(scene.GraphLookup(lx.symbol.sGRAPH_SHADELOC))
texLoc = shaderGraph.FwdByIndex(imageMap, 0)
clipItem = shaderGraph.FwdByIndex(imageMap, 1)
@nicelifeBS
nicelifeBS / edgeSelSets.py
Last active January 4, 2016 15:39
modo script - Query edge selection sets and give out their name
#python
## lx layerservice ##
layerService = lx.Service("layerservice")
layerService.select("layers", "main") # select active mesh layer
nVmaps = layerService.query("vmap.N") # get vmap number
# walk through the vmaps and print the names of it if the type is edgepick
for vmap in xrange(nVmaps):
@nicelifeBS
nicelifeBS / selectMatByName.py
Created January 27, 2014 09:58
modo script - select a material by its name
#python
##--------------------------------------------##
#
# Author Bjoern Siegert 2014-01-27
#
# Slect a material by name if it is
# in the scene.
# Name is defined by an argument just after
# the script name
@nicelifeBS
nicelifeBS / oiiotool_multich
Last active January 24, 2016 07:14
oiiotool: Create multi channel exr
# "chappend" appends all channels of all images in the stack
# "chnames" renames the appended channels
oiiotool input1.exr input2.exr --chappend --chnames R,G,B,A,input2_label.R,input2_label.G,input2_label.B,input2_label.A -o output.exr