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 / 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:
@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 / 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")
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 / 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]);
@petfactory
petfactory / build_tiles.py
Last active August 29, 2015 14:05
Random uv and mesh tiling
import maya.cmds as cmds
import random
import math
def build_tiled_mesh_uv(mesh, num, t_offset, rot_scale, item_per_row_uv, item_per_row_xform):
#get the x and z spacing [ xmin ymin zmin xmax ymax zmax ]
bb = cmds.xform(mesh, q=True, bb=True)
x_dist = bb[3] - bb[0]
z_dist = bb[5] - bb[2]
@petfactory
petfactory / AE Expression
Last active August 29, 2015 14:05
AE expression
// linear interpolation between position 100,100 to 500,500
// from 0 to 3 seconds
linear(time,0,3,[100,100],[500,500])
// drop the frame rate to 1fps on existing keyframes,
posterizeTime(1);
value;
// could use with the linear function (no keyframes needed)
posterizeTime(1);
@petfactory
petfactory / set_bool_knob.py
Created September 17, 2014 09:48
Toggle a bool knob in nuke
def set_bool_knob(name, all=True, value=None):
if all:
node_list = nuke.allNodes()
else:
node_list = nuke.selectedNodes()
for node in node_list:
@petfactory
petfactory / tableview_delegate.py
Created January 13, 2015 07:36
PySide tableview delegate test
from PySide import QtCore, QtGui
from shiboken import wrapInstance
import maya.OpenMayaUI as omui
def maya_main_window():
main_window_ptr = omui.MQtUtil.mainWindow()
return wrapInstance(long(main_window_ptr), QtGui.QWidget)
import nuke
import os.path
sel_nodes = nuke.selectedNodes()
frame = nuke.frame()
node = sel_nodes[0]
file_path = nukescripts.replaceHashes( node['file'].value() ) % frame