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 / uiModelExportEntry.py
Created September 19, 2017 01:11
idTech Model Export Entry (PySide Designer Generated)
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Users\nstevenson\AppData\Roaming\Luxology\Scripts\europa\uiModelExportEntry.ui'
#
# Created: Wed Apr 06 21:26:20 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.4
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui
@nicholas-stevenson
nicholas-stevenson / uiMain.py
Last active October 7, 2017 04:26
idTech Main Module (PySide Designer Generated)
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Users\nstevenson\AppData\Roaming\Luxology\Scripts\doom\uiMain.ui'
#
# Created: Wed Apr 06 21:26:20 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.4
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui
@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:
@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 / 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 / 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 / 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 / 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 / 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 / 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