Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
SEVEZ / mirror_names.py
Last active February 25, 2016 18:59
Match selected object names by their symetrical position across X. If L_arm matches R_leg, L-arm -> L_leg.
import maya.cmds as mc
eps = 1E-5
sel = mc.ls( sl=1 )
while sel:
v = mc.xform( sel[0], q=1, rp=1, ws=1 )
import maya.OpenMaya as OpenMaya
selection = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList( selection )
iterSel = OpenMaya.MItSelectionList(selection, OpenMaya.MFn.kMesh)
while not iterSel.isDone():
dag_path_object = OpenMaya.MDagPath()
iterSel.getDagPath( dag_path_object )
from PySide import QtCore, QtGui
from shiboken import wrapInstance
import maya.OpenMayaUI as mui
mainWin = wrapInstance(long(mui.MQtUtil.mainWindow()), QtGui.QWidget)
action = QtGui.QAction(mainWin)
action.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Tab))
action.setShortcutContext(QtCore.Qt.ApplicationShortcut)
@SEVEZ
SEVEZ / Normals_from_polys.py
Created October 3, 2015 12:11
Normals from selected polygons
import maya.cmds as cmds
faces = cmds.filterExpand(sm=34, ex=True)
verts = cmds.ls((cmds.polyListComponentConversion(faces, ff=True, tv=True)), flatten=True)
normals = [[], [], []]
for v in verts:
conFaces = cmds.ls(cmds.polyListComponentConversion(v, fv=True, tf=True), flatten=True)
shaFaces = list(set(conFaces).intersection(set(faces)))
@SEVEZ
SEVEZ / PS_trUV.py
Last active February 2, 2021 02:05
Transfer current uv set from last selected object to current uv sets of all others #Final
import maya.cmds as mc
sel = mc.ls( sl=1 )
sUV = mc.polyUVSet( sel[-1], q=1, cuv=1 )[0]
for d in sel[:-1]:
mc.transferAttributes( sel[-1], d, uvs=1, suv=sUV, tuv=mc.polyUVSet( d, q=1, cuv=1 )[0], col=0, spa=0, sm=3, fuv=0, clb=0, pos=0, nml=0 )
@SEVEZ
SEVEZ / PS_perspOrthoToggl_v3.py
Last active July 5, 2025 20:07
Switch between perspective and matching orthographic view. The latest version is v3. #Release
# Latest version, uses Tumble Pivot Point viewport
# feature, and proprietary algorithm, works in all recent
# versions of Maya, Python 2.7 / 3+. Gives more predictable
# and stable results.
# Pavel Sevets 2022
import maya.cmds as mc
import maya.api.OpenMaya as om
from math import pi
@SEVEZ
SEVEZ / MatFaceFinder.mel
Last active September 6, 2015 21:18
Select one face on an object. Run MatFaceFinder. This script will select all of the faces strictly on that object which share the same material assignment as the first face.
// SCRIPT NAME: MatFaceFinder.mel v1.1 (Maya2009 version)
// AUTHOR: Thomas Hamilton
// LAST UPDATED: November 16, 2009
// www.thomashamilton.org
//DESCRIPTION:
//Select one face on an object. Run MatFaceFinder. This script will select all of the faces
//strictly on that object which share the same material assignment as the first face.
@SEVEZ
SEVEZ / PS_Attach.py
Last active February 12, 2021 22:53
Attach meshes to last selected, keeping pivots, transforms and hierarchy. Remake of script by Thomas Hamilton from here http://www.creativecrash.com/maya/script/attachmaster #WIP
import maya.cmds as mc
import string
def PS_Attach( objs ):
def dag_par( obj ):
if isinstance( obj, basestring ):
return string.join( mc.listRelatives( obj, pa=1, f=1 )[0].split('|')[:-1], '|' )
@SEVEZ
SEVEZ / ehm_flattenDeformer2.py
Created August 31, 2015 08:25
Simple flatten deformer
'''
import maya.cmds as cmds
if not cmds.pluginInfo( 'ehm_flattenDeformer2.py', l=1, q=1 ):
if cmds.loadPlugin( 'ehm_flattenDeformer2.py') == None:
cmds.warning('Failed to load plugin.')
# Apply the deformer
cmds.deformer( name="Flatten_Deform", type='ehm_flattenDeformer2' )
@SEVEZ
SEVEZ / extend_polysel_to_shell.py
Created August 30, 2015 18:16
Extend polygons selection to shell
import maya.OpenMaya as om
import maya.cmds as cmds
def expandSelection():
sel = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sel)
dag = om.MDagPath()
obj = om.MObject()
# get the active object (dag) and its selected components (obj)
sel.getDagPath(0, dag, obj)