Skip to content

Instantly share code, notes, and snippets.

@rockjail
rockjail / rotationAnglesFromMatrix.py
Created September 21, 2014 12:55
This script builds a rotation matrix based on 3 selected verts. It then calculates the euler angles.
#python
import lx
import lxu.vector
import math
# this something I got from stackoverflow some time ago
# if you'd like to know more about it have a look at this: http://www.soi.city.ac.uk/~sbbh653/publications/euler.pdf
def getRot2(m):
if m[0][0] == 1.0:
x = math.atan2(m[0][2],m[2][3])
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This Command will smooth the transition between two conected curves.
"""
import lx
import lxu.command
import lxifc
# !/usr/bin/env python
#sunFlower
# base on https://commons.wikimedia.org/wiki/File:SunflowerModel.svg
# also because of http://community.thefoundry.co.uk/discussion/topic.aspx?f=4&t=114228
# main thread http://community.thefoundry.co.uk/discussion/topic.aspx?f=4&t=114228
# small changes to include the orientation
# eulerToMatrix function from here: https://gist.github.com/Farfarer/4fb11fc8d4290241e92b
import lx
import math
#python
import lx
import lxifc
SERVER_NAME= "mop.2PointCurve"
class pointVisitor(lxifc.Visitor):
def __init__(self, pointObj, markMode):
self.pointObj = pointObj
self.values = []
@rockjail
rockjail / meshOpCurveGroup.py
Created January 4, 2018 08:49
Manual implementation of a MeshOperation in python for Modo. This is an example showing how to read from a CurveGroup on items connected on a custom graph.
#python
import lx
import lxu
import lxifc
sSERVER_NAME = "mopCurveGroup"
sGRAPH_NAME = sSERVER_NAME + ".graph"
sGRAPH_USERNAME = sSERVER_NAME + ".graphUserName"
sCHAN_COUNT = "count"
import lx
import lxu.meta
class StringLength(lxu.meta.ChannelModifier):
def init_chan(self, desc):
desc.add ("input", lx.symbol.sTYPE_STRING)
desc.chmod_value (lx.symbol.fCHMOD_INPUT)
desc.add ("length", lx.symbol.sTYPE_INTEGER)
desc.chmod_value (lx.symbol.fCHMOD_OUTPUT)
import lx
import modo
scene = modo.Scene()
# default is nuke-default:sRGB
default8bitColorSpace = scene.sceneItem.channel("def8bitColorspace").get()
# create color mapping service instance
colorMappingService = lx.service.ColorMapping()