Skip to content

Instantly share code, notes, and snippets.

@benmorgantd
Created August 21, 2017 20:47
Show Gist options
  • Save benmorgantd/019ed6000982b11392b529870422f0a3 to your computer and use it in GitHub Desktop.
Save benmorgantd/019ed6000982b11392b529870422f0a3 to your computer and use it in GitHub Desktop.
Skin Weight Painting Tools for Maya
import maya.cmds as cmds
import maya.mel as mel
# bm_paintTools
# Intelligent tools for attribute painting
# optional values of op (operation) are absolute and smooth. Absolute replaces
def floodSelection(value=0, op="absolute"):
if len(cmds.ls(sl=1)) == 0:
return
# if we're not currently in the paint skin weights tool context, get us into it
if cmds.currentCtx() != "artAttrSkinContext":
mel.eval("ArtPaintSkinWeightsTool;")
# first get the current settings so that the user doesn't have to switch back
currOp = cmds.artAttrSkinPaintCtx(cmds.currentCtx(), q=1, selectedattroper=1)
currValue = cmds.artAttrSkinPaintCtx(cmds.currentCtx(), q=1, value=1)
# flood the current selection to zero
# first set our tool to the selected operation
cmds.artAttrSkinPaintCtx(cmds.currentCtx(), e=1, selectedattroper=op)
# change the tool value to the selected value
cmds.artAttrSkinPaintCtx(cmds.currentCtx(), e=1, value=value)
# flood the tool
cmds.artAttrSkinPaintCtx(cmds.currentCtx(), e=1, clear=1)
# set the tools back to the way you found them
cmds.artAttrSkinPaintCtx(cmds.currentCtx(), e=1, selectedattroper=currOp)
cmds.artAttrSkinPaintCtx(cmds.currentCtx(), e=1, value=currValue)
def selectionToVerts():
# converts the selection to verticies and gets us into the paint skin weights tool
mel.eval("ConvertSelectionToVertices;")
if cmds.currentCtx() != "artAttrSkinContext":
mel.eval("ArtPaintSkinWeightsTool;")
@nader2kix
Copy link

nader2kix commented Nov 1, 2020

_/ _
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment