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 / CrvSkinPercent.py
Last active August 29, 2015 14:17
Curve SkinPercent
pm.system.openFile('/Users/johan/Documents/Projects/python_dev/scenes/spring_jnts.mb', f=True)
ik_jnt_list = [pm.PyNode('joint{0}'.format(j+1)) for j in range(5)]
pos_list = [j.getTranslation(ws=True) for j in ik_jnt_list]
crv = pm.curve(d=1, p=pos_list)
crv_shape = crv.getShape()
crv_shape.overrideEnabled.set(1)
@petfactory
petfactory / nukeWebView.py
Created April 3, 2015 05:40
Load a web view
from PySide import QtCore, QtGui, QtWebKit
class MyWidget(QtGui.QDialog):
def __init__(self, parent, url):
super(MyWidget, self).__init__(parent)
# set window stuff
self.setWindowTitle('Hello Tree Widget')
@petfactory
petfactory / datetime_dir.py
Created April 6, 2015 13:37
Create a dir from datetime
import datetime
import os
time_string = datetime.datetime.now().strftime("%Y-%m-%d %H.%M.%S")
#print(time_string)
dir_name = 'playblasts {0}'.format(time_string)
root_path = r'/Users/johan/Desktop/test'
dir_path = os.path.join(root_path, dir_name)
@petfactory
petfactory / pyside_gradient.py
Last active November 8, 2022 16:16
Using a maya gradient control with PySide
from PySide import QtCore, QtGui
from shiboken import wrapInstance
import maya.OpenMayaUI as omui
from functools import partial
import pymel.core as pm
def maya_main_window():
main_window_ptr = omui.MQtUtil.mainWindow()
return wrapInstance(long(main_window_ptr), QtGui.QWidget)
#lattice = pm.lattice( dv=(2, 2, 2), oc=True)
#pm.select('{0}.pt[4:7]'.format(lattice[1]),r=True)
def move_lattice(lattice, pos_id_dict):
for id, pos in pos_id_dict.iteritems():
x, y, z = id
pm.select('{0}.pt[{1}][{2}][{3}]'.format(lattice, x, y, z),r=True)
import maya.api.OpenMaya as om
import pymel.core as pm
def intersect_mesh(pos, vec, mesh_name):
selectionList = om.MSelectionList()
selectionList.add(mesh_name)
dagPath = selectionList.getDagPath(0)
fnMesh = om.MFnMesh(dagPath)
import pymel.core as pm
pm.newFile(f=True)
# create the ctrl, add attr and set som keys
ctrl, _ = pm.circle(n='ctrl')
ctrl.addAttr('anim', k=True)
pm.setKeyframe(ctrl, v=0, attribute='anim', t=1)
pm.setKeyframe(ctrl, v=10, attribute='anim', t=25)
pm.setKeyframe(ctrl, v=0, attribute='anim', t=50)
import maya.api.OpenMaya as om
import pymel.core as pm
rot_order = 5
kRotateOrders = [om.MEulerRotation.kXYZ,
om.MEulerRotation.kYZX,
om.MEulerRotation.kZXY,
om.MEulerRotation.kXZY,
om.MEulerRotation.kYXZ,
import pymel.core as pm
import math
w = 200
h = 200
rw = 50
rh = 50
num_rect_width = float(w)/rw
import math
def fit_center_rect(total_length, item_length):
ret_list = []
float_fit = float(total_length)/item_length
int_fit = int(math.ceil(float_fit))
# add one to the count if we have an even number