Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / channelRead.py
Created July 28, 2016 17:23
modo channel reading API
# @author David Ballesteros
#
# @brief Helper classes to deal with the read and write of Item Channels.
# Based on a ChannelRead class sample code provided by Matt Cox
import lx
class ChannelRead:
def __init__(self, item):
"""
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class TableModel(QtCore.QAbstractTableModel):
"""
A simple 5x4 table model to demonstrate the delegates
@nicelifeBS
nicelifeBS / QItemDelegate.py
Created September 5, 2016 09:53
QItemDelegate and QAbstractListModel
import sip
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class SpinBoxDelegate(QtGui.QItemDelegate):
def createEditor(self, parent, option, index):
editor = QtGui.QSpinBox(parent)
editor.setMinimumHeight(100)
@nicelifeBS
nicelifeBS / katana_layout_widgets.py
Created February 24, 2017 09:47
KATANA: How to layout widget like Katana does it
import UI4.FormMaster.PythonValuePolicy
# Create a node for which to create parameter widgets
node = NodegraphAPI.CreateNode('Alembic_In', NodegraphAPI.GetRootNode())
# Get a couple of parameters from the node
addForceExpandParameter = node.getParameter('addForceExpand')
addBoundsParameter = node.getParameter('addBounds')
fpsParameter = node.getParameter('fps')
@nicelifeBS
nicelifeBS / teleparam.py
Created February 25, 2017 02:14
Katana: Create a teleparameter
def CreateTeleParam(parentParam, targetParam):
teleParam = parentParam.createChildString(
'%sTeleParam' % targetParam.getName(), '')
teleParam.setExpression('getParam("%s").param.getFullName()'
% targetParam.getFullName())
teleParam.setHintString(repr({'widget': 'teleparam'}))
@nicelifeBS
nicelifeBS / db_upload.py
Created June 25, 2017 10:06
dropbox: upload large files
f = open(file_path)
file_size = os.path.getsize(file_path)
CHUNK_SIZE = 4 * 1024 * 1024
if file_size <= CHUNK_SIZE:
print dbx.files_upload(f, dest_path)
else: