Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
EricTRocks / XMLtoDirStruct.py
Created February 4, 2013 19:59
Script to create directories from an XML file.
import os
import xml.etree.ElementTree as ET
DEBUG = 0
strXML = """<?xml version='1.0'?>
<dir>
<dir name="images">
<dir name="nuke" />
<dir name="maya" />
@EricTRocks
EricTRocks / getKeys
Last active December 19, 2015 02:09
getting softimage key frame time/value
import win32com.client
from win32com.client import constants
from win32com.client import Dispatch as disp
from xml.etree import ElementTree as ET
from xml.etree.ElementTree import tostring
import base64
import traceback
#-------------------------- Import Python base modules.
@EricTRocks
EricTRocks / softimage_bakeToICEAttr.py
Last active February 28, 2016 20:53
This is a snippet of code that can be used to bake per frame point positions of a mesh in Softimage to an ICE Attribute for local storage. This code hasn't been tested in this form and has been extracted from a larger tool. May need some editing / optimization.
# Baking point positions to an ICE attribute for local caching.
# Eric Thivierge
from win32com.client import Dispatch
from win32com.client import constants
si = Application
log = LogMessage
sel = si.Selection
@EricTRocks
EricTRocks / QSliderWithText.py
Created April 19, 2016 19:41
QSlider with Text showing Value
from PySide import QtCore, QtGui, QtOpenGL
class SliderWithValue(QtGui.QSlider):
def __init__(self, parent=None):
super(SliderWithValue, self).__init__(parent)
self.stylesheet = """
@EricTRocks
EricTRocks / Mat442DArray.py
Created April 21, 2016 19:04
How to create a 2DArray of RTVals
import FabricEngine.Core as fabric
client = fabric.createClient()
client.loadExtension("Math")
matrixA = client.RT.types.Mat44()
matrixB = client.RT.types.Mat44()
matrixC = client.RT.types.Mat44()
matrixD = client.RT.types.Mat44()
@EricTRocks
EricTRocks / RTValStringName.py
Created April 22, 2016 18:39
Get the string name of an RTVal type
import FabricEngine.Core as fabric
client = fabric.createClient()
client.loadExtension("Math")
mat44 = client.RT.types.Mat44()
print mat44.getTypeName().getSimpleType()
@EricTRocks
EricTRocks / InterpolateWithBias.kl
Created April 26, 2016 22:50
Interpolate between 2 values with bias
// Calculate the twist blend with bias
Scalar bias = 0.5;
Integer divisions = 5;
Scalar fraction = Scalar(i) / Scalar(divisions - 1);
Scalar biasBlend = fraction / ((((1.0 / bias) - 2.0) * (1.0 - fraction)) + 1.0);
Scalar blend = Math_linearInterpolate(0.0, 1.0, biasBlend);
@EricTRocks
EricTRocks / KL.sublime-build
Last active May 12, 2016 16:42
Sublime Text build config for Fabric Engine KL code
{
"cmd": ["D:/fabric/FabricEngine-2.2.0-Windows-x86_64/bin/kl.exe", "--loadexts", "$file"],
"env": {
"PATH": "D:/fabric/FabricEngine-2.2.0-Windows-x86_64/bin",
"FABRIC_DIR": "D:/fabric/FabricEngine-2.2.0-Windows-x86_64",
"FABRIC_EXTS_PATH": "D:/fabric/FabricEngine-2.2.0-Windows-x86_64/Exts;",
"FABRIC_DFG_PATH": "D:/fabric/FabricEngine-2.2.0-Windows-x86_64/Presets/DFG;"
},
"selector": "source.kl",
"file_regex": "(?:]|:|^) ?([A-Za-z]:?[^:\\]]*\\.kl):(\\d+):(\\d+): (?:error:|warning:) (.+)$"
@EricTRocks
EricTRocks / QueryMayaMainWindowWidth.py
Created May 25, 2016 14:26
Get the width of the Maya main window in PyMel
import pymel.core as pm
main_window = pm.ui.Window(pm.MelGlobals.get('gMainWindow'))
width = pm.window(main_window, query=True, width=True)
print width
@EricTRocks
EricTRocks / NodePortDefValue.py
Last active June 30, 2016 16:01
Get default value from instanced Fabric node in Python
import FabricEngine.Core
import json
# import FabricEngine.Core.CAPI as capi
client = FabricEngine.Core.createClient({'guarded': True})
client.loadExtension('Math')
client.loadExtension('Kraken')
registeredTypes = client.RT.types