Created
May 16, 2019 01:02
-
-
Save pmolodo/668d9809873125f608e0f7360fff7fac to your computer and use it in GitHub Desktop.
Removing a addPolyComponentIdChangedCallback can cause a crash (Maya 2019)
This file contains 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
#execfile('/Volumes/home/paulm/Desktop/testPolyComponentIdChanged.py') | |
import maya.cmds as cmds | |
import maya.api.OpenMaya as om | |
cmds.file(f=1, new=1) | |
cubeTrans = cmds.polyCube()[0] | |
cubeShape = cmds.listRelatives(cubeTrans)[0] | |
sel = om.MSelectionList() | |
sel.add(cubeShape) | |
mobj = sel.getDependNode(0) | |
def myPolyComponentCallback(*args, **kwargs): | |
print "poly components changed!" | |
polyCompCbid = om.MPolyMessage.addPolyComponentIdChangedCallback(mobj, (True, True, True), myPolyComponentCallback) | |
def removeCallbacks(*args, **kwargs): | |
print "removing callbacks..." | |
om.MMessage.removeCallback(polyCompCbid) | |
del globals()['polyCompCbid'] | |
polyDestroyCbid = om.MNodeMessage.addNodeDestroyedCallback(mobj, removeCallbacks) | |
cmds.refresh() | |
cmds.undo() | |
cmds.refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment