Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
SEVEZ / PS_perspOrthoToggl_v3.py
Last active January 11, 2024 10:50
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 / Toggle_wireframe.mel
Created August 24, 2017 21:58
Toggle wireframe
// Toggle wireframe
global proc NS_toggleWF()
{
string $currentPanel = `getPanel -withFocus`;
if ("" != $currentPanel && ("modelPanel" == `getPanel -to $currentPanel`))
{
string $myToggle = `modelEditor -q -displayAppearance $currentPanel`;
@SEVEZ
SEVEZ / check_uv_flips_overlaps.py
Created August 29, 2015 11:18
Maya Python script for selecting overlapped and flipped uv polygons
import math
import maya.api.OpenMaya as om
from pymel.core import *
from pymel.core.datatypes import *
def createBoundingCircle(meshfn):
"""Parameter: meshfn - MFnMesh
Represent a face by a center and radius, i.e.
center = [center1u, center1v, center2u, center2v, ... ]
radius = [radius1, radius2, ... ]
@SEVEZ
SEVEZ / RGB_hue_shift_on_RYB_wheel.js
Created August 29, 2015 11:23
Shift RGB colors along RYB artistic color wheel
// 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;
@SEVEZ
SEVEZ / hotkeys.py
Created May 11, 2016 18:58 — forked from danbradham/hotkeys.py
Autodesk Maya hotkeys with Python
import maya.cmds as cmds
import maya.mel as mel
from maya.utils import executeDeferred
from functools import wraps
import re
def defer(fn):
'''Delays execution of the decorated function until Maya is available.'''
@wraps(fn)
# WORKS ONLY IN LEGACY VIEWPORT
import maya.OpenMaya as om
import maya.OpenMayaMPx as mpx
import sys
kPluginCtxName = 'myContext'
kPluginCmdName = 'myContextCmd'
@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 / 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 / getUvShells.py
Last active November 20, 2020 20:45 — forked from paulwinex/getUvShells.py
Get all UV shells from mesh object
import maya.OpenMaya as om
import maya.cmds as cmds
def getUvShelList(name):
selList = om.MSelectionList()
selList.add(name)
selListIter = om.MItSelectionList(selList, om.MFn.kMesh)
pathToShape = om.MDagPath()
selListIter.getDagPath(pathToShape)
meshNode = pathToShape.fullPathName()
@SEVEZ
SEVEZ / snap_loc_to_geo.py
Created August 29, 2015 11:22
Create locator on surface of any visible mesh object
import maya.cmds as cmds
import pymel.core as pm
import maya.api.OpenMaya as om
import maya.api.OpenMayaUI as omui
class SamsClass():
def __init__(self):
pass