Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Onefabis / colorAttributes
Created October 3, 2019 16:21
Plugin for colorizer script in order to attribute color in the channel box
import ast
import sys
import maya.api.OpenMaya as om2
import maya.cmds as mc
import colorsys
# Plug-in information:
kPluginNodeName = 'colorAttributes'
kPluginNodeClassify = 'utility/general'
kPluginNodeId = om2.MTypeId( 0x86025 )
import maya.cmds as mc
selDrivers = mc.textScrollList( "driverObjects", q=1, si=1 )
if not selDrivers:
selDrivers = mc.ls( sl=1 )
outPlug = mc.listConnections( selDrivers, c=1, d=1, s=0 )
if outPlug:
animCurves = outPlug[1::2]
animCurvesU = [ a for a in animCurves if 'animCurveU' in mc.ls( a, st=1)[-1] ]
if animCurvesU:
drivens = mc.listConnections( animCurvesU, c=1, d=1, s=0 )
@Onefabis
Onefabis / fastTextureReplacePath
Last active August 30, 2019 22:17
Fast replace textures paths for maya in case textures folders was changed
import os.path
import maya.cmds as mc
'''
you can call script from this command at the end of the code
fastTextureReplacePath()
it will search based on the path of your scene, i.e., it will seek inside subfolders in the folder where your scene is
@Onefabis
Onefabis / GameExpFromTimelineMarkers
Created August 6, 2019 13:13
Autofill game exporter from timelineMarkers data
import maya.mel as mel
import maya.cmds as mc
import os
import json
path = mc.file(q=1, sn=1).rsplit( '/', 1 )[0]
stored = mc.fileInfo( "timelineMarkers", q=1 )
if stored: info = json.loads( stored[ 0 ].replace( '\\"', '"') )
else: info = dict()
frames = info.get( "frames" ) or []
@Onefabis
Onefabis / GrowSkinWeights
Created June 3, 2019 14:22
Grow Skin Weights from selected vertices to adjacent vertices
import maya.api.OpenMaya as om2
import maya.api.OpenMayaAnim as oma2
import maya.cmds as mc
class growSkinWeights(object):
def __init__(self):
self.cIds = None
def growSkinDo(self, mode):
@Onefabis
Onefabis / GrowSkinWeights
Created June 3, 2019 14:22
Grow Skin Weights from selected vertices to adjacent vertices
import maya.api.OpenMaya as om2
import maya.api.OpenMayaAnim as oma2
import maya.cmds as mc
class growSkinWeights(object):
def __init__(self):
self.cIds = None
def growSkinDo(self, mode):
@Onefabis
Onefabis / spaceObjects
Created April 13, 2019 03:58
space objects evenly
import maya.cmds as mc
import maya.api.OpenMaya as om2
def spread(x,objType='spaceLocator'):
sel = mc.ls( sl=1 )
if len(sel) != 2:
mc.warning('Please select two objects')
return
pos1 = mc.xform( sel[0], q=1, ws=1, t=1 )
@Onefabis
Onefabis / addToGroup.py
Last active April 10, 2019 20:41
Quickly add selected objects into empty group for every selected object
import re
import maya.cmds as mc
def addToGroup( *args ):
post,replacePost,postIndex,dupIgnore = parseArgs( args )
allObj = mc.ls( sl=1, l=1 )
rootNode = [ a.rsplit('|',a.count('|')-1 )[0] if a.count('|') > 1 else a for a in allObj ]
newHi = sum( ( [ k for k in mc.listRelatives( m, ad=1, typ='transform', f=1 ) ] + [m] if mc.listRelatives( m, ad=1, typ='transform', f=1 ) else [m] for m in list( set( rootNode ) ) ), [] )
hiSel = [ x for x in newHi if x in allObj ]
newNObjects = []
for a in hiSel:
@Onefabis
Onefabis / noFlipRivet
Created February 28, 2019 22:22
noflip rivet
import maya.cmds as mc
class randomScatter():
def _init_(self):
if mc.window("randSelection", exists=1):
mc.deleteUI("randSelection")
mc.window("randSelection", t="WithOutFlip_Rivet - Avijit Das", w=405, sizeable=0)
mc.rowColumnLayout(nc=3,cal=[(1,"right")], cw=[(1,100),(2,200),(3,105)])
mc.rowColumnLayout(w=405)
mc.text("Select two Edge the click Rivet", height=20)
mc.separator(height=20, style='in')
@Onefabis
Onefabis / refSearch
Last active February 19, 2019 00:31
Quickly search and add referenced files from directory
'''
Author: Alexander Smirnov
The script will quickly search and add referenced files from directory you will enter in the main text field
Icon buttons from the lower right corner simply the same as the native maya ones
Start will launch the 'scriptJob' that monitoring any reference scene request before opening
Stop will delete the 'scriptJob'