I want an Open Maya getter and setter for locking a vertex's pnt attribute.
I am currently using Maya's standard cmds
, but it is too slow.
This is my getter:
mesh = cmds.ls(sl=1)[0]
vertices = cmds.ls(cmds.polyListComponentConversion(mesh, toVertex=True), flatten=True)
cmds.getAttr("{}.pntx".format(vertices[0]), lock=True)
This is my setter:
mesh = cmds.ls(sl=1)[0]
vertices = cmds.ls(mc.polyListComponentConversion(mesh, toVertex=True), flatten=True)
cmds.setAttr("{}.pntx".format(vertices[0]), lock=False)
This is what I have so far, in Open Maya:
import maya.api.OpenMaya as om
sel = om.MSelectionList()
sel.add(meshes[0])
dag = sel.getDagPath(0)
fn_mesh = om.MFnMesh(dag)
I think I need to pass the vertex object into an om.MPlug()
so that I can compare the pntx attribute against the MPlug
's isLocked
function, but I'm not sure how to achieve this.
I have a suspicion that I need to get it through the om.MFnMesh()
, as getting the MFnMesh
vertices only returns ints
, not MObjects
or anything that can plug into an MPlug
.