Skip to content

Instantly share code, notes, and snippets.

@nicelifeBS
nicelifeBS / sel_renderpass_channels.py
Created July 20, 2016 09:58
Selecting channels of an item in a render pass
import modo
import lx
scene = modo.scene.current()
selected = scene.selected[0]
list = []
rp = scene.renderPassGroups[0]
for ch in rp.groupChannels:
g=ch.item.itemGraph('xfrmCore')
@nicelifeBS
nicelifeBS / CustomPreviewRender.py
Created May 30, 2016 10:48
Modo python API: Create a custom preview render and write its image to disk as png in sRGB color space
import lx
import modo
ImgSrv = lx.service.Image()
colorService = lx.service.ColorMapping()
TosRGB = lx.object.ColorMapping(colorService.MakeColorMapping("nuke-default:sRGB", 0))
width = 1000
height = 800
@nicelifeBS
nicelifeBS / non-blocking_stdout_stream.py
Created April 15, 2016 00:41
Run a subprocess and output stdout in a non-blocking fasion
import subprocess
import threading
def _print_stdout(process):
'''
Print out the stream line by line. If line is empty we know that the process has finished and we exit
'''
while True:
try:
line = process.stdout.readline()
@nicelifeBS
nicelifeBS / meshSelListener.py
Created February 27, 2016 06:32 — forked from boredstiff/meshSelListener.py
meshSelListener.py
#python
import lx
import lxu.object
import lxu.command
import lxifc
class AwSelListener(lxifc.SelectionListener):
running = False
@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
# 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)
# python
""" Short snippet demonstrating how you can edit scene item's name using MODO 701 Python API.
"""
import lx
import lxu.select
PREFIX = 'prefix_'
# 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
@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
@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):