To store and restore selection after d_raster MultiCut use in Maya 2015 i tried to write a tiny Qt eventFilter.
There are several modes in MultiCut tool. We work with CTRL+LMB mode (this mode creates edgeloops).
To store selected components i create sets for verts,edges and faces.
Then MultiCut perform geometry changes.
And after that we restore selected components from sets.
The problem is that i tried different types of QEvent and still can’t handle\catch moment after MultiCut tool change geometry to add “restore from sets” block of code.
# KEY: <filename>.MultiCut.start()
# it's automatically starts Maya MultiCut context
import maya.cmds as mc
from functools import partial
import maya.mel as mel
import maya.OpenMayaUI as apiui
import PySide.QtCore as qtc
import PySide.QtGui as qtg
class XSIMultiCut(qtc.QObject):
q_app = qtg.QApplication.instance()
blocked = False
def start( self ):
mel.eval('dR_multiCutTool')
self.q_app.installEventFilter( self )
return True
def eventFilter( self, obj, event ):
etype = event.type()
if mc.currentCtx()=='nexMultiCutCtx1' and etype == qtc.QEvent.MouseButtonRelease and not self.blocked:
button = event.button()
mods = event.modifiers()
if button == qtc.Qt.LeftButton and mods == qtc.Qt.ControlModifier:
self.blocked = True
print "
BEFOR SEND
"
self.q_app.sendEvent( obj, event )
print "
AFTER SEND
"
self.blocked = False
return True
return False
MultiCut = XSIMultiCut()
And here ScriptEditorLog