This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.all import * | |
def selectEdgeLoop(): | |
edge = ls( sl=1, fl=1 )[0] | |
shp = PyNode( ls( hl=1 )[0] ).getShape() | |
vertices = edge.connectedVertices() | |
newEdges = [] | |
newEdges.append( edge ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMaya as om | |
import maya.cmds as cmds | |
def edgeCapSelector(): | |
# Check if vertices or faces were selected. | |
# If True convert selection to edges. | |
verts = cmds.filterExpand(sm = 31, ex = True, fullPath = True) | |
faces = cmds.filterExpand(sm = 31, ex = True, fullPath = True) | |
if verts is not None or faces is not None: | |
cmds.ConvertSelectionToEdges() | |
# Create variable of special class MScriptUtil. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WORKS ONLY IN LEGACY VIEWPORT | |
import maya.OpenMaya as om | |
import maya.OpenMayaMPx as mpx | |
import sys | |
kPluginCtxName = 'myContext' | |
kPluginCmdName = 'myContextCmd' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMaya as OpenMaya | |
import maya.OpenMayaUI as OpenMayaUI | |
def selectAllVisibleObjectsFromScreen(): | |
activePane=OpenMayaUI.M3dView.active3dView() | |
w=activePane.portWidth() | |
h=activePane.portHeight() | |
myX=OpenMaya.MScriptUtil() | |
myX.createFromInt(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mDagPathFromName( name ): | |
selList = OpenMaya.MSelectionList() | |
selList.add( str( name ) ) | |
mDagPath = OpenMaya.MDagPath() | |
selList.getDagPath( 0, mDagPath ) | |
return mDagPath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
from pymel.core import * | |
from pymel.core.datatypes import * | |
import maya.OpenMaya as om | |
import maya.OpenMayaUI as omui | |
class SamsClass(): | |
ctx = cmds.currentCtx() | |
cto = cmds.contextInfo(ctx,c=1) | |
print cto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getScreenRes(panel): | |
m3v = OpenMayaUI.M3dView.active3dView() | |
OpenMayaUI.M3dView.getM3dViewFromModelPanel(panel, m3v) | |
xPtr = OpenMaya.MScriptUtil().asUintPtr() | |
yPtr = OpenMaya.MScriptUtil().asUintPtr() | |
widthPtr = OpenMaya.MScriptUtil().asUintPtr() | |
heightPtr = OpenMaya.MScriptUtil().asUintPtr() | |
m3v.viewport(xPtr, yPtr, widthPtr, heightPtr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use M3dView. | |
def screenPositionAPI(panel, pos): | |
mp = OpenMaya.MPoint(pos[0], pos[1], pos[2]) | |
m3v = OpenMayaUI.M3dView.active3dView() | |
OpenMayaUI.M3dView.getM3dViewFromModelPanel(panel, m3v) | |
xp = OpenMaya.MScriptUtil().asShortPtr() | |
yp = OpenMaya.MScriptUtil().asShortPtr() | |
ret = m3v.worldToView(mp, xp, yp) | |
x = OpenMaya.MScriptUtil().getShort(xp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMaya as om | |
import maya.cmds as cmds | |
def expandSelection(): | |
sel = om.MSelectionList() | |
om.MGlobal.getActiveSelectionList(sel) | |
dag = om.MDagPath() | |
obj = om.MObject() | |
# get the active object (dag) and its selected components (obj) | |
sel.getDagPath(0, dag, obj) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
import maya.cmds as cmds | |
if not cmds.pluginInfo( 'ehm_flattenDeformer2.py', l=1, q=1 ): | |
if cmds.loadPlugin( 'ehm_flattenDeformer2.py') == None: | |
cmds.warning('Failed to load plugin.') | |
# Apply the deformer | |
cmds.deformer( name="Flatten_Deform", type='ehm_flattenDeformer2' ) |