Skip to content

Instantly share code, notes, and snippets.

View JFlynnXYZ's full-sized avatar
🦝

Jonny Flynn JFlynnXYZ

🦝
View GitHub Profile
import pymel.core as pm
def get_mat_assigned_for_obj(mat, obj):
if issubclass(type(mat), (str, unicode)):
mat = pm.PyNode(mat)
if issubclass(type(obj), (str, unicode)):
obj = pm.PyNode(obj)
members = mat.connections(type=pm.nt.ShadingEngine)[0].members()
import random as r
from argparse import ArgumentParser
import sys
def main(args):
switch = not args.no_switch
successful_hits = 0
for i in range(args.tries):
correct_door = r.randint(0, 2)
doors = [True if x == correct_door else False for x in xrange(3)]
@JFlynnXYZ
JFlynnXYZ / .bash_git
Created October 29, 2017 19:00
Old Bash Scripts from Uni
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
# -*- coding: utf-8 -*-
"""Hello World ToolBar UI for use in Maya Plugins
This module demonstrates a method of tracking instances used in Maya Plugins.
This method stores all instances that the plugin creates in the base class and
uses static methods to delete all of those instances.
Example:
If you wish to test this code without using the plugin simple execute the
same code shown below:
@JFlynnXYZ
JFlynnXYZ / pyside_dynamic.py
Created February 7, 2017 12:10 — forked from cpbotha/pyside_dynamic.py
pyside_dynamic.py with minor improvements - also see http://stackoverflow.com/a/14894550/532513
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Sebastian Wiesner <lunaryorn@gmail.com>
# Modifications by Charl Botha <cpbotha@vxlabs.com>
# * customWidgets support (registerCustomWidget() causes segfault in
# pyside 1.1.2 on Ubuntu 12.04 x86_64)
# * workingDirectory support in loadUi
# found this here:
# https://github.com/lunaryorn/snippets/blob/master/qt4/designer/pyside_dynamic.py
@JFlynnXYZ
JFlynnXYZ / renderVectorUVs.py
Last active March 20, 2024 11:25
Code to convert a Maya Polygon object's UV's to an SVG render vector uvs
import maya.api.OpenMaya as om
import maya.cmds as cmds
import os.path
import svgwrite
STROKE_LINECAP = ("butt", "round", "square")
def check_reverse_line_drawn(newLineCoords, drawnLines):
@JFlynnXYZ
JFlynnXYZ / frontierScripts.py
Last active April 17, 2016 15:37
Frontier Rigging Script Jobs
def resetMcRestPosition(joints, ctrl, ikHand):
'''Reset Multi chain rest position'''
ikHand.ikBlend.set(0)
for j in joints:
j.rotate.set((0,0,0))
ctrl.translate.set((0,0,0))
ikHand.ikBlend.set(1)
def resetMcRotX(joints, ikHand):
@JFlynnXYZ
JFlynnXYZ / Modelling.py
Last active March 14, 2016 15:50
UsefulMayaLibrary
MERGE_FACE_DIRECTION = {"+x":0, "-x":1, "+y":2, "-y":3, "+z":4, "-z":5}
def getBoundaryEdges(obj=None):
if obj == None:
obj = pm.selected()[0]
objType = type(obj)
if objType == pm.nt.Mesh:
edges = obj.edges
elif objType == pm.nt.Transform:
for /f "delims== tokens=2" %a in ('assoc .pdf') do @ftype %a
@JFlynnXYZ
JFlynnXYZ / find_non_unique.py
Created December 17, 2015 14:52
Find and select all non unique nodes in a Maya scene
allDagNodes = cmds.ls(dag=True, sn=True)
allDagNodesLong = cmds.ls(dag=True, sn=False)
nonUnique = [ node for node in allDagNodes if '|' in node ]
values=[]
for n in nonUnique:
for ln in allDagNodesLong: