This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------------------- | |
# - pompVertNormFaceAvg | |
# | |
# - Sets the vertex normals of a face selection, | |
# averaging normals shared by multiple selected faces. | |
# | |
# | |
# - by Pontus Karlsson 2013 (www.pomperi.com) | |
# --------------------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.OpenMaya as om | |
fileNodes = cmds.ls(sl=1) | |
width = 1024 | |
height = 1024 | |
image = om.MImage() | |
for i in fileNodes: | |
filePath = cmds.getAttr(i+'.fileTextureName') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tempfile | |
os.startfile( tempfile.gettempdir() ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PyQt | |
from PyQt4 import QtCore, QtGui | |
import sip | |
long(sip.unwrapinstance( obj )) | |
sip.wrapinstance(long(ptr), QtCore.QObject) | |
sip.wrapinstance(long( OpenMayaUI.MQtUtil.mainWindow() ), QtCore.QObject ) | |
# PySide | |
from PySide import QtGui, QtCore | |
import shiboken |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="joint")) | |
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="nurbsCurve")) | |
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="constraint")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Preview online | |
// http://www.deathbysoftware.com/colors/index.html | |
function rgb2ryb ( iRed, iGreen, iBlue ) | |
{ | |
// Remove the white from the color | |
var iWhite = Math.min( iRed, iGreen, iBlue ); | |
iRed -= iWhite; | |
iGreen -= iWhite; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.all as pm | |
def get_selected_uv_shells(): | |
sel = pm.selected(o = True)[0] | |
selected_uvs = set(uv for uv in pm.selected() if isinstance(uv, pm.MeshUV)) | |
# getUvShellsIds returns a list of shell_ids, and the number of shells | |
uv_shell_ids, num_shells = sel.getUvShellsIds() | |
# You still need to actually get the MeshUVs yourself | |
# Using sets instead of sublists because checking if an item is in a set is much faster | |
all_shells = [set() for i in xrange(num_shells)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getUVShells(shape, uvSet=None): | |
uvSets = cmds.polyUVSet(shape, q=True, allUVSets=True) | |
if not uvSet or uvSet not in uvSets: | |
uvSet = cmds.polyUVSet(shape, q=True, cuv=True)[0] | |
selectionList = om.MSelectionList() | |
selectionList.add(shape) | |
mDag = om.MDagPath() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selection = cmds.ls(sl = True) | |
for model in selection: | |
refcheck = cmds.referenceQuery(model, inr = True) | |
if (refcheck == 1): | |
reftodel = cmds.referenceQuery(model, f = True) | |
cmds.file(reftodel, rr = True) | |
cmds.file(newfile, r=True) | |
else: | |
cmds.delete(model) | |
cmds.file(newfile, i=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
def dragAttr( attr_names ): | |
if not cmds.dragAttrContext('dragAttributeCtx', ex=True): | |
cmds.dragAttrContext('dragAttributeCtx') | |
cmds.dragAttrContext( 'dragAttributeCtx', e=True, ct=attr_names ) | |
cmds.setToolTo( 'dragAttributeCtx' ) | |
dragAttr( "Push_Deform2.inflation" ) |