PyMEL
General
Pymel wraps around the mel, python.cmds. and maya.openmaya.
Python has its default
os.path
module. PyMEL also has its own implementation. They are not mutually exclusive. You can use both in one script.nt is node type. dt is data type
- PENDING: Assign materials in PyMel (https://discourse.techart.online/t/assigning-a-material-using-pymel/1240/9)
Test
TO DO
script to determine in maya if there is a difference between the skinculster one and off
1# Get object based on name
2obj = pm.PyNode('pCube1')
3obj = pm.nt.Joint('joint1')
4objects = pm.ls(['Object_A', 'Object_B'])
5
6# Get objects selected
7obj = pm.selected()
8
9# Select all based on node type
10obj_sel = pm.ls(type="displayLayer")
11
12# Select all based on wildcard search
13obj_sel = pm.ls("*_con") # wild card search
14obj_sel = pm.ls("*Sphere*", type = "transform") # wild card search
15
16# Get node based on nodetype
17# connections method only work on the shape node
18for node in obj.getShape().connections():
19 if node.nodeType() == 'skinCluster':
20 print (node.nodeType())
21 sc_node = node
22
23# Alternative on getting the shape and actually any other connection depending on the index
24pm.selected()[0].listHistory()[0]
25
26# Alternative on getting the skinCluster node
27pm.PyNode('pCube1').listHistory(type="skinCluster")
28
29# Determine if the verts are on boundary
30for vert in shapeNode.verts:
31 if vert.isOnBoundary():
32 doSomething()
Links
Most of the links here are old presentation. Fortunately, there’s not much changes in Maya API and as such most of them are still applicable. There might be some syntax difference since Maya switched to Python 3 on 2022 release.
`Rigging Dojo Live Jason Parks Power Python for Maya <https://www.youtube.com/watch?v=vTMomfVYmH4&ab_channel=RiggingDojo>`__(30 Jan 2013)