question of undo Error
Hi. i am a newbie studying max python scirpt.
I am writing this post because of the undo problem of max Pyside.
If you create the UI of the code below
You can not use undo (Ctrl + Z) after creating a box
#======================================= # Error Scirpt #======================================= from PySide import QtGui from PySide import QtCore import MaxPlus as mp import pymxs class BaseWindow(): def __init__(self, title='custom_UI', width=300, height=100): self.win = QtGui.QWidget( parent = mp.GetQMaxWindow() ) self.win.resize(width, height) self.win.setWindowTitle(title) self.main_layout = QtGui.QVBoxLayout() self.win.setLayout(self.main_layout) self.btn = QtGui.QPushButton('MakeBox') self.main_layout.addWidget(self.btn ) def get_window(self): return self.win def show(self): self.win.show() if __name__ =='__main__': def makeBox(evt=None): ns = pymxs.__ContextExpr('undoon') try : shape = mp.Factory.CreateGeomObject(mp.ClassIds.Box) node = mp.Factory.CreateNode( shape ) finally : ns = pymxs.__ContextExpr('undooff') win = BaseWindow() win.show() win.btn.clicked.connect(makeBox)
but Using this code below
You can use the undo (Ctrl + Z) function.
# not Error scirpt def test(evt=None): ns = pymxs.__ContextExpr('undoon') try : shape = mp.Factory.CreateGeomObject(mp.ClassIds.Box) node = mp.Factory.CreateNode( shape ) finally : ns = pymxs.__ContextExpr('undooff') if __name__ =='__main__': test(evt=None)
The only difference is that you just connect to the pyside button with make box funtion.
What is the solution of this?
I searched the internet all day yesterday. I do not know.
so. I upload this question. Please help me.
version : 3ds Max 2017