Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Onefabis / setupTensionMap
Last active February 8, 2019 20:36
Quickly add tension map to your skinned mesh
sel = mc.ls( sl=1 )
if mc.ls( mc.listRelatives( sel[0], s=1 )[0], st=1 )[-1] == 'mesh':
if not mc.pluginInfo( 'tensionMap', q=11, l=1 ):
mc.loadPlugin( 'tensionMap' )
tensionMN = mc.createNode('tensionMap')
plug = mc.connectionInfo( sel[0] + '.inMesh', sourceFromDestination=1 )
if plug:
mc.connectAttr( plug, tensionMN + '.deform', f=1 )
mc.connectAttr( mc.listRelatives( sel[0], s=1 )[-1] + '.worldMesh[0]', tensionMN + '.orig', f=1 )
mc.connectAttr( tensionMN + '.out', sel[0] + '.inMesh', f=1 )
'''
This plugin was ported to python from C++,
All credits by Anno Schachner
original plugin is here https://github.com/wiremas/tension
'''
import sys
import maya.api.OpenMaya as om2
import maya.OpenMaya as om
@Onefabis
Onefabis / angleMeasure
Last active January 11, 2019 22:36
angle measure construction script that show angle in real time between two vectors
'''
Select three components and run the script.
Remember that selection order matters, so the second one will display the angle between 1-2 vector and 2-3 vector.
'''
import maya.cmds as mc
# make sure that tracking of selection order is turned on
if not mc.selectPref( q=1, trackSelectionOrder=1 ):
mc.selectPref( trackSelectionOrder=1 )
# get ordered component selection
objs = mc.ls( os=1, fl=1 )
@Onefabis
Onefabis / inMeshPlace
Last active October 13, 2018 13:24
Inserts object inside mesh just in the middle of the of the intersection of the camera ray and all geo in the scene
'''
Instructions:
To run the script just ise the code:
________________________________________________________________
import inMeshPlace
inMeshPlace.start()
________________________________________________________________
@Onefabis
Onefabis / jointLabel
Created September 26, 2018 19:45
Add label to selected joints
import maya.cmds as mc
sl=mc.ls( sl=1 )
nLabel = None
side = None
for s in sl:
if s.startswith( 'L_' ) or s.startswith( 'Left_' ):
try:
nLabel = s.replace( 'L_', '' )
side = 1
@Onefabis
Onefabis / colorizer
Last active October 3, 2019 16:19
controller colorizer for maya
'''
Author: Alexander Smirnov
Version: 1.0
Instruction:
Just paste in script editor this two lines to launch the script:
import colorizer
colorizer.start()
@Onefabis
Onefabis / quickProxySkinned
Created September 26, 2018 02:55
Quickly create skinned proxy mesh
import maya.api.OpenMaya as om2
import maya.cmds as mc
import proxySkinning
reload(proxySkinning)
def duplicateSkinnedMesh(joints):
# get selected components
sel = om2.MGlobal.getActiveSelectionList()
for s in xrange( sel.length() ):
'''
To launch the script run the code:
import pickWalker
reload(pickWalker)
pickWalker.pW().ui()
Assign hotkey to walk in up direction
import pickWalker
@Onefabis
Onefabis / mouseClickModelPanel.py
Created May 24, 2018 21:32
Detect mouse button clicks in every modelPanel Editor
import maya.cmds as mc
import maya.OpenMayaUI as apiUI
from PySide2 import QtGui, QtCore, QtWidgets
from shiboken2 import wrapInstance
class MouseDetector(QtCore.QObject):
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.MouseButtonPress:
if event.button() == QtCore.Qt.LeftButton:
print 'left'
@Onefabis
Onefabis / createCsPoly.py
Last active October 22, 2022 11:11
create Custom Shape polygon
import sys
import maya.api.OpenMaya as om2
import maya.cmds as mc
def maya_useNewAPI():
pass
##########################################################
# csPoly Node.