I’m attempting to get some really basic OpenMaya2 code going. Right now I’m just trying to delete. I haven’t found many examples online for such a simple thing.
I’m creating a bunch of locators. After I create each one, I’m just attempting to delete it. (If anyone knows of a way to delete all of them via OM that’d be great info to have too!).
I’m getting a Maya hard crash on the below code when calling mod.doIt()
. In deleteNode
I’ve tried the mobject, the dagpath, and dag node. Nothing seems to take. The mobject throws an error of # RuntimeError: (kInvalidParameter): Object is incompatible with this method #
. I thought mobject would be the way to go?
Any help here is appreciated!
import maya.cmds as cmds
import maya.api.OpenMaya as om
for i in range(0, 99):
loc = cmds.spaceLocator()
cmds.select(loc, add=True)
loc_sl = om.MGlobal.getActiveSelectionList()
ldag, lmobj = loc_sl.getComponent(0)
om.MDagPath
mod = om.MDGModifier()
mod.deleteNode(ldag.node())
mod.doIt() # <----crash!