Skip to content

Instantly share code, notes, and snippets.

View nicholas-stevenson's full-sized avatar

Nicholas Stevenson nicholas-stevenson

View GitHub Profile
@nicholas-stevenson
nicholas-stevenson / renameSel.py
Created January 13, 2016 22:28
Rename Selected Object: This file is a Modo plugin that allows you to select and item and rename it. I have this mapped to the F2 key since it closely matches what my operating system uses for renaming. To install this, take the file below and place it inside your Modo's /Scripts/lxserv/ folder. This folder is automatically accessed by Modo as t…
#!/usr/bin/env python
__author__ = 'Nicholas Stevenson'
__email__ = 'twistedsheep@gmail.com'
import lx
import lxu
import lxu.select
#import lxifc
class RenameSel(lxu.command.BasicCommand):
@nicholas-stevenson
nicholas-stevenson / copyNamesToClipboard.py
Last active January 13, 2016 22:33
Copy Names to Clipboard: This file is a Modo plugin that allows you copy the current selected item names to your System Clipboard. I have this mapped to the F3. To install this, take the file below and place it inside your Modo's /Scripts/lxserv/ folder. This folder is automatically accessed by Modo as the files contained are considered plugins.…
#python
import lx, lxu, modo
from PySide import QtGui
class copyNamesToClipboard(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__(self)
def basic_Execute(self, msg, flags):
@nicholas-stevenson
nicholas-stevenson / lx_vs_modo.py
Last active January 13, 2016 22:36
This file is an example of Modo's Lx, Lxu python modules, and how they compare to the new TD SDK available in Modo 901.
#!/usr/bin/env python
# List Cameras and their Focal Lengths
#
# Classic Modo Python
#
import lx, lxu
# Create a scene selection service object
@nicholas-stevenson
nicholas-stevenson / ListComprehension.py
Created January 13, 2016 22:38
List Comprehensions: This is an example of list comprehensions and what they do. The code in the middle section is how you create a list of items who don't have parents. The code at the very end is how you achieve the same thing using a list comprehension. List comprehensions are used everywhere in Python and are very, very useful.
import modo
sceneItems = modo.Scene().items()
# In this example, we're going to get all the items in the scene
# that don't have any parents. In short, only root items.
# The long way of doing this would be...
rootItems = [] # Start with an empty list
@nicholas-stevenson
nicholas-stevenson / PrintMeshItems.py
Created January 14, 2016 02:08
Example Code to print out all meshes in the currently selected scene.
import modo
scene = modo.Scene() # Create and save a modo Scene item in the variable named scene
# This is the mesh item type
meshType = modo.c.MESH_TYPE # you can also use 'mesh' in its place
# but using the item type is considered a better practice
meshes = scene.items(itype=meshType) # The scene object allows you to give it an item type
# if you only need a specific type of items.
@nicholas-stevenson
nicholas-stevenson / AlphabetizeMeshes.py
Created January 14, 2016 02:53
Modo script to alphabetize all mesh items in the current scene.
import modo
scene = modo.Scene() # Create and save a modo Scene
# item in the variable named scene
meshItems = scene.items(itype='mesh') # Get all mesh items in the current scene
# Using a list comprehension, go through
rootMeshes = [item for item in meshItems if item.parent is None] # each mesh object and only keep those
# that don't have parents.
@nicholas-stevenson
nicholas-stevenson / StoreAndFetchData.py
Last active January 29, 2016 12:31
Example code, plucked from a tool of mine, that stores its data on an in-scene object, using a standard string channel.
# Data storage to and from the in-scene node
def storeData(self, data):
node = self.getNode()
ModelData = json.dumps( data[ModelEntries], sort_keys=True )
AnimationData = json.dumps( data[AnimationEntries], sort_keys=True )
lx.eval('item.channel item:{%s} name:{%s} value:{%s}' %(node.UniqueName(), ModelEntries, ModelData))
lx.eval('item.channel item:{%s} name:{%s} value:{%s}' %(node.UniqueName(), AnimationEntries, AnimationData))
@nicholas-stevenson
nicholas-stevenson / main.py
Last active September 19, 2017 01:18
idTech Main Module
import modo, lx, lxu, os, json, ast
import doom.uiMain
import doom.uiModelExportEntry
from PySide import QtCore, QtGui
# This is the default in-scene attribute that will be created and stored on our primary data node
# It will hold the pickled data as a string.
# The data node will hold the DataAttribute as a string. Our internal data will be pickled and written to
# this attribute
@nicholas-stevenson
nicholas-stevenson / md5.py
Last active September 19, 2017 01:25
md5 mesh format exporter and importer
import lx, lxu, lxifc
import modo
import sys, os, math, datetime
__author__ = 'Nicholas Stevenson'
__date__ = 'October 2015'
# Huge thanks David Henry for his web site dissecting the format and contents of id's md5mesh and md5anim files.
# His work made creating this much, much easier.
@nicholas-stevenson
nicholas-stevenson / idTechWrapper.py
Last active September 19, 2017 01:18
idTech Layout Register Plugin
import lx
import lxifc
import PySide
from PySide import QtGui
import doom.main
class idTechExporter(lxifc.CustomView):
def customview_Init(self, pane):
if pane == None: