Skip to content

Instantly share code, notes, and snippets.

View JFlynnXYZ's full-sized avatar
🦝

Jonny Flynn JFlynnXYZ

🦝
View GitHub Profile
@JFlynnXYZ
JFlynnXYZ / centre_objects.py
Last active August 29, 2015 13:57
Centres a selection of objects to the first selected object's rotate pivot.
import maya.cmds as cmds
def _centre_objects(*args):
'''Centres a selection of object's to the first selected objects
rotate pivot.
args : This is a list of objects that can also be used by
the user. If this is blank, then a selection is used instead.
On Exit : Moves all of the objects apart from the first to the
@JFlynnXYZ
JFlynnXYZ / Maya GUI Gists
Last active February 5, 2022 10:12
Maya GUI Gists
Here is just a selection of GUI gists I've written which I have found useful when creating my own GUI's.
Hope you find them useful!
@JFlynnXYZ
JFlynnXYZ / fit_to_group_bbox.py
Last active August 29, 2015 13:58
Fits an object to the size of a group/objects world bounding box (used for 3d Projections and Planar Mapping)
import maya.cmds as cmds
def fit_to_group_bbox(obj, group):
'''Used to scale and translate a 3d projection node used for planar
mapping onto the size of a group or object. I haven't found any
other use for it as of yet, but I have kept the variables open
in-case someone does.
obj : is the name of the object or projection you want to
resize
@JFlynnXYZ
JFlynnXYZ / listSelShapeRelatives.py
Last active August 29, 2015 14:09
List Shape/Mesh Relatives for Selected Objects and Render Pass Primary Visibility
#Creats a list of all selected objects name of shape/mesh node
import maya.cmds as cmds
cmds.listRelatives(cmds.ls(selection=True), type='mesh')
@JFlynnXYZ
JFlynnXYZ / offset.py
Last active August 29, 2015 14:14
Offset Animation Keyframes
'''Allows a simple offset of all keyframes from a list of selected objects.
selection => all of the currently selected objects in the seen. This will be the translate nodes for each object.
time=(0,100) => set this to the time range of the animation
'''
selection = cmds.ls(selection=True)
for s in selection:
cmds.keyframe('%s.rotateX' % s, edit=True, time=(0,100) ,valueChange=90, relative=True)
import maya.cmds as cmds
for win in cmds.lsUI(windows=True):
cmds.window(win, e=True, tlc=[0,0])
@JFlynnXYZ
JFlynnXYZ / ctrlCreator.py
Last active November 28, 2015 16:45
Creates a ctrl at a selected joint
import maya.cmds as cmds
def getInheritedRotation(obj):
rotation = [0,0,0]
p = cmds.listRelatives(obj, allParents=True)
while p != None:
if cmds.nodeType(p) != "joint":
@JFlynnXYZ
JFlynnXYZ / ctrCreator_hierarchy.py
Last active November 28, 2015 17:42
Creates circle ctrls around a hierarchy of joints
import maya.cmds as cmds
from collections import namedtuple
PivotCtrl = namedtuple("PivotCtrl", "jnt ctrl sdk offset")
def getInheritedRotation(obj):
rotation = [0,0,0]
p = cmds.listRelatives(obj, allParents=True)
@JFlynnXYZ
JFlynnXYZ / autoRig_finger.py
Created November 28, 2015 18:26
Some of my auto rigging scripts that I'm compiling. Still need to work on annotating.
import maya.cmds as cmds
from collections import namedtuple
PivotCtrl = namedtuple("PivotCtrl", "jnt ctrl sdk offset")
def getInheritedRotation(obj):
rotation = [0,0,0]
p = cmds.listRelatives(obj, allParents=True)
@JFlynnXYZ
JFlynnXYZ / parseHashURL.js
Last active January 21, 2016 09:23
Takes parameters form a url after a # in the form of <formID>=<value>& Source: http://htmlasks.com/pre_fill_form_field_via_url_in_html
var hashParams = window.location.hash.substr(1).split('&'); // substr(1) to remove the `#`
if (hashParams[0] != ""){
for(var i = 0; i < hashParams.length; i++){
var p = hashParams[i].split('=');
document.getElementById(p[0]).value = decodeURIComponent(p[1]);
}
}