class Example(QtGui.QWidget): def __init__(self, parent=None): super(Example, self).__init__() self.initUI() self.setup_connections()
def initUI(self): self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Rename')
self.list_widget = QtGui.QListWidget() self.add_loc_btn = QtGui.QPushButton("Add new Locator")
vlayout = QtGui.QVBoxLayout() vlayout.addWidget(self.list_widget) vlayout.addWidget(self.add_loc_btn) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_connections(self): self.add_loc_btn.clicked.connect(self.add_locator) self.list_widget.itemDoubleClicked.connect(self.list_item_dbl_click) self.list_widget.itemChanged.connect(self.list_item_click)
def add_locator(self): new_loc = cmds.spaceLocator() loc_fp = cmds.ls(new_loc[0], long=True) loc_item = QtGui.QListWidgetItem(str(new_loc[0])) loc_item.setData(32, loc_fp[0]) loc_item.setFlags( loc_item.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEditable ) self.list_widget.addItem(loc_item)
def list_item_dbl_click(self): current_item = self.list_widget.currentItem() self.prev_name = current_item.text() self.rename_counter = 1
def list_item_click(self, test): success = False current_item = self.list_widget.currentItem() list_item_row = self.list_widget.currentRow() new_name = current_item.text()
if self.validate_naming(new_name): locator = current_item.data(32) if cmds.objExists(locator) and self.rename_counter == 1: cmds.select(locator) cmds.rename(new_name)
# reset counter back to 0 self.rename_counter = 0 success = True
else: # Set back to its initial naming before rename current_item.setText(self.prev_name)
if success: list_item = self.list_widget.item(list_item_row) self.list_widget.setCurrentItem(list_item)
def validate_naming(self, name_input): if re.search("^\s*[0-9]", name_input): LOG.warning("Input naming cannot be started off with numbers!") return False return True
myWin = Example()myWin.show()
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/63af8ecf-5d67-4004-a076-34fc68019d9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi, I have not. I was not aware of the above 2 you have mentioned. This may sounds very noobish of me - but how do I use them?
Additionally, I could be wrong on this but while I was googling around, trying to find a way, I chanced upon Model View Controller (something that I was not aware of too).It seems that this case of MVC may or may not be applicable in my cause, but what is the best scenario to use MVC then?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8a569a28-2fa2-43a7-ba54-9bc5152008cf%40googlegroups.com.
Got it, thanks!Is there a way in which I can also use script job to detects when my custom tool is closed?I am using `MayaQWidgetDockableMixin` in which the `closeEvent` is not calling (`dockCloseEventTriggered` does gets called and executed if the tool is docked) and it is not removing the scriptjobs that I have created..
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/42b20895-e304-4b11-9902-e9d48d0bf24e%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Hey Justin, I'm guessing you meant to set self._has_init = True in showEvent()
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/42b20895-e304-4b11-9902-e9d48d0bf24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9cfa56fb-e524-4bb7-a667-0ab6a3430eb5%40googlegroups.com.
Thank you Justin. Will try out your method.I have 2 questions here:1. For the approach I have adopted - 'using scriptJob to track tool closure' , is that still applicable/advisable?
2. And one more question - For the `undo` that I have implemented, eg. perform an un-renaming process, I noticed that it takes me to press the 'undo' combination 7 times just to get the name of the node back to its initial naming, instead of the 1 time that I am expecting....Any insights on this?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f2508104-18ae-430e-8616-c42bcd24a98f%40googlegroups.com.
Could you kindly elaborate more on `rename wasn't wrapped in an Undo group`? I am not quite understanding here...I did not create any 'groups' (cmds.undoInfo) if you are referring to that...
And unfortunately, there seems to be another issue where - when trying to select any keys in the Graph Editor (it did a super quick select and unselect action), seemingly caused by the scriptjobs I have created...
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9cfbf62f-17f1-4722-8656-23cefed88cc1%40googlegroups.com.
Thought I placed my files here as I could not really figure out the undo or the graph editor selection...main.py - https://pastebin.com/aQL9Fvue
refplanes.py - https://pastebin.com/zzKkFYxcutils.py - https://pastebin.com/SXidXLTHrefplanes_ui.py - https://pastebin.com/qCGGqZEFAppreciate in advance if anyone could shed any lights on it.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a4cd6401-5ec7-468b-92ea-86edcb9f41bf%40googlegroups.com.
def create_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', openChunk=True)
def remove_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', closeChunk=True)
Hi Justin, thank you for getting back.As for the DockWidget() class method you have provided, sadly it does not seems to be working for me. Getting the same issue (signal not getting called) as soon as `self.ui.setupUi(self)` is implemented.
-----I tried using the following in my main.py for the `cmds.undoInfo` as follows:
def create_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', openChunk=True)
def remove_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', closeChunk=True)
It seems that I am the undo actions are not getting compress into 1 action... Am I doing it wrong?Also tried implementing the above code in my execution code, not seeing any diff...
-----Noted on the global usage for script jobs tracking.As for the selections, I made it that way because, I need to achieve 2 things.1. Whatever that is selected in the Maya context (image planes in this case), if found in the tool context, selects the said item in the tool (which is under QListWidget).2. Selection made in the tool context - QListWidget (again, only the image plane selection), will be selected in the Maya context if found.Basically a bi-directional selection between my tool and Maya. As you have suggested, upon the removal of the `cmds.select` in the `plane_selected()` seems to have did the trick in the key selection in Graph Editor! Thank you.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d08aae7f-cf31-499f-b629-4e1b284874a9%40googlegroups.com.
cmds.undoInfo(query=True, printQueue=True)
# Returns the following result:
...
# 39: # # 40: # # 41: # # 42: # # 43: MyTool_chunkName # # 44: # # 45: # # 46: # # 47: # # 48: # # 49: #