Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Onefabis / MagicSave.py
Last active April 4, 2019 18:06
Saves the new version of the file with right numeric postfix. For instance, ex.ma will be saved as ex_01.ma. ex_02.ma will be saved as ex_03.ma, etc.
'''
_______________________________________
Name: magicSave
Version: 1.1
Author: Alexander Smirnov
e-mail: [email protected]
site: fabis.xyz
_______________________________________
Instructions:
@Onefabis
Onefabis / moveCurrentToDefaultUVSet.py
Last active October 11, 2016 19:55
Transfers current UV set to the default one
# Transfer current UV to the default one
import maya.cmds as mc
import maya.mel as mel
x=0
if not mc.selectMode( q=1, object=True ):
x=1
mel.eval('toggleSelMode; ')
mel.eval('changeSelectMode -object;')
selO=[]
@Onefabis
Onefabis / MayaHandfulSnipplets.py
Last active August 2, 2016 15:45
Prints elements id of selected elements
import maya.api.OpenMaya as om2
#get vertices ID of selected faces
sel = om2.MSelectionList()
sel = om2.MGlobal.getActiveSelectionList()
dp, comp = sel.getComponent(0)
mItVtx = om2.MItMeshPolygon(dp,comp)
idx = []
while not mItVtx.isDone():
point = mItVtx.getVertices()
@Onefabis
Onefabis / slider_template.py
Last active December 13, 2018 06:50
Custom slider for maya
from PySide import QtGui,QtCore
import maya.OpenMayaUI as mui
import shiboken
import sys
class AttrFieldGroup(QtGui.QWidget):
valueChanged = QtCore.Signal(float)
def __init__(self, parent=None):
super(AttrFieldGroup, self).__init__(parent)
@Onefabis
Onefabis / 0_reuse_code.js
Created June 30, 2016 19:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Onefabis
Onefabis / toggle_visible_layer.py
Created July 12, 2016 18:13
The script can toggle reference<=>default state of visible layers
import maya.cmds as cmds
layers = cmds.ls( type='displayLayer')
global chLayViz
try:
chLayViz
except NameError:
chLayViz = None
if chLayViz == 0 :
chLayViz = 1
@Onefabis
Onefabis / skinTweakTool.py
Last active July 27, 2016 15:11
Allows to tweak skin weights more precise in Maya.
import maya.cmds as mc
from functools import partial
class skinTweakTool( object ):
def __init__( self ):
global stInfluenceObjects
try:
stInfluenceObjects
except:
stInfluenceObjects = None
@Onefabis
Onefabis / deleteNonIntKeys.py
Created July 27, 2016 19:25
deletes the keys with decimal time
import maya.cmds as mc
import maya.mel as mel
selObj = mc.ls( sl=1 )
aPl = mel.eval('$tmpVar=$gPlayBackSlider')
trg = mc.timeControl( aPl, q=1, ra=1 )
if( trg[1]-trg[0]>1 ):
sttr = trg[0]
endtr = trg[1]
else:
@Onefabis
Onefabis / jointInTheCenter
Created October 18, 2016 14:01
Create joint in the center of the component selection
clst = mc.cluster()
pos = mc.xform( clst[1], q=1, ws=1, rp=1 )
mc.joint( p=pos, a=1 )
mc.select( cl=1 )
mc.delete( clst[0] )
name = mc.keyframe( q=1, n=1, sl=1 )
objs = mc.ls( sl=1, l=1 )
global glAnCurves
try:
glAnCurves
except:
glAnCurves = []
if len( glAnCurves ) >0 :
mc.selectionConnection( 'graphEditor1FromOutliner', e=1, clr=1 )
allCh = [ g.rsplit( '.', 1 )[0] for g in glAnCurves ]