Skip to content

Instantly share code, notes, and snippets.

View petfactory's full-sized avatar
💭
Testing Flask

Johan Borgström petfactory

💭
Testing Flask
View GitHub Profile
@petfactory
petfactory / normalToCamera.js
Created April 24, 2013 14:36
This snippet makes sure that a layer is facing the camera. All tribute to Dan Ebberts - www.motionscript.com
L = thisComp.layer("Camera 1");
u = fromWorldVec(L.toWorldVec([1,0,0]));
v = fromWorldVec(L.toWorldVec([0,1,0]));
w = normalize(fromWorldVec(L.toWorldVec([0,0,1])));
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
from maya import cmds
from maya import OpenMayaUI
from PySide import QtCore
from PySide import QtGui
from shiboken import wrapInstance
import os
# testing to load a transparent 24 png from the script dir
usrScriptDir = cmds.internalVar(userScriptDir=True)
img_path = os.path.join(usrScriptDir, "lighthouse_24_alpha.png")
@petfactory
petfactory / PySideMayaTest_loadPng_v01.py
Created April 18, 2013 09:37
PySide Maya experimentation. Testing to load a transparent png.
from maya import cmds
from maya import OpenMayaUI
from PySide import QtCore
from PySide import QtGui
from shiboken import wrapInstance
import os
# testing to load a transparent 24 png from the script dir
usrScriptDir = cmds.internalVar(userScriptDir=True)
img_path = os.path.join(usrScriptDir, "lighthouse_24_alpha.png")
@petfactory
petfactory / MayaPySideTablayout.py
Created April 17, 2013 12:33
Testing out PySide in Maya 2014. Creating a simple Tab layout with some buttons. Not sure if this is the "proper" way to do it. Copied some stuff from a Nuke PySide test I did a while back. Seems to work though. Feedback are of course welcome.
from PySide import QtCore, QtGui
from shiboken import wrapInstance
import maya.OpenMayaUI as apiUI
import sys
def getMayaWindow():
"""
Get the main Maya window as a QtGui.QMainWindow instance
@return: QtGui.QMainWindow instance of the top level Maya windows
"""
@petfactory
petfactory / VrayID.py
Last active December 15, 2015 16:18
Loops through all materials and if it has a VRay material ID it prints the material name, the ID and if selectMaterial is set to True it selects the materials.
import pymel.core as pm
import pymel.core.general
# select materials
allMat = pm.ls(materials=True)
vrayID = {}
selectMaterial = True
for mat in allMat: