I’ve been doing a lot of Python lately. Mainly to script Maya to better optimize things that would normally take too long, but also outside of it, and I think I’ve gotten the hang of it by now.
So I figured I’d head into the API stuff now, wanting to make deformers mainly (animator background) but also rigging aids and some other cool stuff.However scripting and using the API in python actually seems very different from one another, and what is even worse is that there doesn’t really seem to be that much to go on if one tries to learn about it.
So far, I’ve gone ahead and bought the David Gould books and figured out some C++ to go along with that. I’ve got some websites going, like this one,
and the Maya docs to try and piece things together. but ultimately it seems I’m going to have to do it the old fashioned way. Learning by doing and that’s why I’m posting here today. I’m looking for some pieces of guidance as I try out some stuff by following the API docs and C++ tutorials from Goulds books. Some of which work real nice, others however do not.
Like this thing.
import maya.OpenMaya as OpenMaya sel = OpenMaya.MSelectionList() OpenMaya.MGlobal.getActiveSelectionList(sel) dagPath = OpenMaya.MDagPath() component = OpenMaya.MObject() vertCount, vertIndex = 0, 0 iter = OpenMaya.MItSelectionList(sel) while not iter.isDone(): dagPath = iter.getDagPath( dagPath, component ) meshIter = OpenMaya.MItMeshVertex( dagPath, component ) # <--- Here it fails iter.next()
It doesn’t really do anthing, I haven’t gotten that far yet. I get that in C++, the dagPath and component objects are both references and that I probably should use MScriptUtil somehow to fake that and pass it along, but I fail to see the logic.
The whole thing returns:
Error: RuntimeError: (kInvalidParameter): Object is incompatible with this method
What am I not thinking of?