Skip to content

Instantly share code, notes, and snippets.

Ivo Grigull ivogrig

Block or report user

Report or block ivogrig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ivogrig
ivogrig / Monitor example
Created Jun 23, 2015
Modo Monitor example
View Monitor example
import time
import lx
dialog_svc = lx.service.StdDialog()
# Allocate monitor
mon = lx.object.Monitor(dialog_svc.MonitorAllocate('Calculating Center Of Mass ...'))
steps = 50
@ivogrig
ivogrig / CmdSetMeshInstance.py
Created Jun 10, 2015
Sets a new source mesh to a mesh instance, by manipulating the 'meshInst' and 'source' graphs.
View CmdSetMeshInstance.py
################################################################################
#
# SetMeshInstance.py
#
# Version: 0.1
#
# Author: Ivo Grigull
#
# Last Update: 10/06/2015
#
@ivogrig
ivogrig / RemoveZeroRotation.py
Last active Nov 21, 2017
Example command for removing zero rotations from a locator item.
View RemoveZeroRotation.py
"""
Example command for removing zero rotations from a locator item.
Clears the zero rotation offset while maintaining the pose. Acts on all selected locator items.
Limitation: Only works if the rotation item's location is subsequent to the zero rotation item
(As by default when using the skeleton tool)
Existing animation curves are removed
Simplified example, no argument handling or command helps/configs added.
@ivogrig
ivogrig / ImagePixel.py
Last active May 21, 2017
Loading an image clip and reading a pixel
View ImagePixel.py
import lxu
import lxu.select
def loadImage(filepath, width, height):
'''
Loads an image as clip and returns it's image interface object.
'''
if not os.path.exists(filepath):
raise AttributeError("Path does not exist")
@ivogrig
ivogrig / pointInCamera.py
Last active Jun 18, 2016
Test is a given point is visible in the camera and Convert between 3d and screen coordinates
View pointInCamera.py
# Test is a given point is visible in the camera
# Convert between 3d and screen coordinates
import modo
# Assuming the camera is also the active view
def pointInCamera(cam, position):
aperture_x = cam.channel(lx.symbol.sICHAN_CAMERA_APERTUREX).get()
aperture_y = cam.channel(lx.symbol.sICHAN_CAMERA_APERTUREY).get()
@ivogrig
ivogrig / CmdSetTag.py
Last active May 7, 2016
Example command to read or write item tags
View CmdSetTag.py
"""Example command to read or write item tags
Example usage:
item.editTag sunLight013 TAGN "Test"
item.editTag sunLight013 TAGN ?
import modo
item = modo.Item('Directional Light')
value = 'Test'
@ivogrig
ivogrig / channelSets.py
Last active Nov 23, 2015
Using channel sets in python
View channelSets.py
import modo
scene = modo.Scene()
# Add a channel set group and select it, so it will display
channelSet = scene.addGroup( name='MyChannelSet', gtype='chanset')
# Create locator and add some channel to the channel set
loc = scene.addItem(modo.c.LOCATOR_TYPE)
@ivogrig
ivogrig / aimRotation.py
Last active Sep 30, 2015
Example method for turning a direction vector into an euler rotation (TD SDK)
View aimRotation.py
# python
#
# Example method for turning a direction vector into an euler rotation
#
# There is a similar example using the API for this by Lukasz Pazera: https://gist.github.com/lukpazera/5994547
# This function really does the same, using the mathutils of the TD SDK
import modo
import math
@ivogrig
ivogrig / CmdSetrCurveEndPoints.py
Created Aug 17, 2015
This command sets or gets the 'Start Control' or 'End Control' state of a curve (not a bezier curve).
View CmdSetrCurveEndPoints.py
'''
This command sets or gets the 'Start Control' or 'End Control' state of a curve (not a bezier curve).
# Example for querying the Start Control state for every curve polygon found in the selected mesh:
import modo
mesh = modo.Mesh()
for curvePolygonIndex in [i.index for i in mesh.geometry.polygons.iterCurves()]:
startControl = lx.eval('curve.endPoints polyIndex:{0} first:?'.format( curvePolygonIndex ))
lx.out(startControl)
@ivogrig
ivogrig / curveEndPoints.py
Created Aug 17, 2015
How to set curve endpoints with the TD SDK
View curveEndPoints.py
import modo
# By not passing an item when initializing the Mesh object,
# it will use the selected if any
curve = modo.Mesh()
# Iterate the curve polygons and activate the endpoints
for polygon in curve.geometry.polygons.iterCurves():
polygon.accessor.SetFirstIsControlEndpoint(1)
polygon.accessor.SetLastIsControlEndpoint(1)
You can’t perform that action at this time.