diff --git a/scripts/blurdeform/blurAddPose.py b/scripts/blurdeform/blurAddPose.py index cb11cc4..d2dc6f0 100644 --- a/scripts/blurdeform/blurAddPose.py +++ b/scripts/blurdeform/blurAddPose.py @@ -71,3 +71,5 @@ def __init__(self, parent=None): self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) self.setWindowTitle("Add New Pose") + + self.refreshWindow() \ No newline at end of file diff --git a/scripts/blurdeform/blurDeformQueryMeshes.py b/scripts/blurdeform/blurDeformQueryMeshes.py index 4894d85..d42c4ff 100644 --- a/scripts/blurdeform/blurDeformQueryMeshes.py +++ b/scripts/blurdeform/blurDeformQueryMeshes.py @@ -15,7 +15,7 @@ class BlurDeformQueryMeshes(Dialog): - def __init__(self, parent=None): + def __init__(self, parent=None, lstMeshes=None, listToSelect=None, addComboMeshes=None): super(BlurDeformQueryMeshes, self).__init__(parent) self.btnClicked = None self.listSelectedMeshes = [] @@ -28,10 +28,12 @@ def __init__(self, parent=None): self.buttonBox.button(QtWidgets.QDialogButtonBox.Yes).setText("Add Selected") self.buttonBox.button(QtWidgets.QDialogButtonBox.YesToAll).setText("Add All") - self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) + # self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) + #self.setWindowModality self.setWindowTitle("Pick meshes to Add") self.addComboMeshes = None + self.refreshWindow(lstMeshes, listToSelect, addComboMeshes) def closeEvent(self, event): self.listSelectedMeshes = [] # same as rejected @@ -56,12 +58,13 @@ def refreshWindow(self, lstMeshes, listToSelect, addComboMeshes): self.listSelectedMeshes = [] self.uiMeshesLW.clear() for ind, nm in enumerate(lstMeshes): - item = QtWidgets.QTreeWidgetItem() + print(nm) + item = QtWidgets.QTreeWidgetItem(self.uiMeshesLW) item.setText(0, nm) item.setFlags( item.flags() | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsUserCheckable ) - self.uiMeshesLW.addTopLevelItem(item) + # self.uiMeshesLW.addTopLevelItem(item) if self.addComboMeshes: cb = QtWidgets.QComboBox(self) diff --git a/scripts/blurdeform/blurdeform.py b/scripts/blurdeform/blurdeform.py index 6b9bc92..58e94a2 100644 --- a/scripts/blurdeform/blurdeform.py +++ b/scripts/blurdeform/blurdeform.py @@ -88,7 +88,7 @@ def getVertsSelection(): continue transform = dagPath.transform() depNode = OpenMaya.MFnDependencyNode(transform) - depNode_name = depNode.name() + depNode_name = cmds.ls(depNode.uniqueName())[0] if component.isNull(): iterSel.next() @@ -149,10 +149,14 @@ def deltasPaste(self): self.blurDeformQueryMeshesWin, modal=True, instanced=True, + lstMeshes=self.currentGeometries, + listToSelect=self.currentGeometries, + addComboMeshes=None + ) - self.blurDeformQueryMeshesWin.refreshWindow( - self.currentGeometries, self.currentGeometries, None - ) + # self.blurDeformQueryMeshesWin.refreshWindow( + # self.currentGeometries, self.currentGeometries, None + # ) selectedMeshes = self.blurDeformQueryMeshesWin.listSelectedMeshes indicesMeshes = list( @@ -351,6 +355,7 @@ def setSelectedVerticestoInBetweenFrame(self): def removeSelectedVerticesFromFrame(self): selectedVertices = getVertsSelection() if not selectedVertices: + cmds.confirmDialog(t="remove verts", m="select some vertices\nFailed") return # get an easy array to deal with indicesMeshes = sorted( @@ -567,12 +572,15 @@ def addNewFrame(self): self, blurDeformQueryMeshes.BlurDeformQueryMeshes, self.blurDeformQueryMeshesWin, - modal=True, - instanced=True, - ) - self.blurDeformQueryMeshesWin.refreshWindow( - listResForDuplicate, objsWithAttributes, None + modal=False, + instanced=False, + lstMeshes=listResForDuplicate, + listToSelect=objsWithAttributes, + addComboMeshes=None ) + # self.blurDeformQueryMeshesWin.refreshWindow( + # listResForDuplicate, objsWithAttributes, None + # ) objsToAdd = self.blurDeformQueryMeshesWin.listSelectedMeshes else: objsToAdd = objsWithAttributes @@ -592,10 +600,14 @@ def addNewFrame(self): self.blurDeformQueryMeshesWin, modal=True, instanced=True, + lstMeshes=selection, + listToSelect=selection, + addComboMeshes=self.currentGeometries + ) - self.blurDeformQueryMeshesWin.refreshWindow( - selection, selection, self.currentGeometries - ) + # self.blurDeformQueryMeshesWin.refreshWindow( + # selection, selection, self.currentGeometries + # ) selectedMeshes = self.blurDeformQueryMeshesWin.listSelectedMeshes for geo, sourceMesh in selectedMeshes: self.doAddNewFrame(self.currentBlurNode, sourceMesh, geo) @@ -631,10 +643,14 @@ def addNewFrame(self): self.refresh(selectTime=True, selTime=cmds.currentTime(q=True)) def doAddNewFrame(self, blurNode, currentGeom, targetMesh): - prt ,= cmds.listRelatives(targetMesh, parent=True, path=True) + # print(blurNode, currentGeom, targetMesh) + prt ,= cmds.listRelatives(targetMesh, parent=True, path=True) or [None] cmds.parent(targetMesh, currentGeom) cmds.makeIdentity(targetMesh, apply=True, translate=False, rotate=True, scale=False, normal=0, preserveNormals=True) - cmds.parent(targetMesh, prt) + if prt is not None: + cmds.parent(targetMesh, prt) + else: + cmds.parent(targetMesh, w=True) poseName = cmds.getAttr(self.currentPose + ".poseName") @@ -2249,7 +2265,7 @@ def selectVertices(self): indexToMesh = {} for ind, msh in indicesMeshes: indexToMesh[ind] = msh - + toHilite=[] for ind in storedVectorsIndices: if ind in indexToMesh: vertices = cmds.getAttr( @@ -2257,14 +2273,17 @@ def selectVertices(self): + ".storedVectors[{}].multiVectorMovements".format(ind), mi=True, ) - toSelect += [ - "{}.vtx[{}]".format(indexToMesh[ind], el) - for el in orderMelList(vertices) - ] + if vertices: + toSelect += [ + "{}.vtx[{}]".format(indexToMesh[ind], el) + for el in orderMelList(vertices) + ] + toHilite.append(indexToMesh[ind]) if toSelect: with extraWidgets.WaitCursorCtxt(): cmds.select(toSelect) + cmds.hilite(toHilite) else: cmds.select(clear=True) @@ -2286,7 +2305,7 @@ def callAddPose(self): modal=False, instanced=True, ) - self.addPoseWin.refreshWindow() + #self.addPoseWin.refreshWindow() def callSaveXml(self): self.toRestore = [] diff --git a/scripts/blurdeform/utils.py b/scripts/blurdeform/utils.py index 03889ff..2fcf549 100644 --- a/scripts/blurdeform/utils.py +++ b/scripts/blurdeform/utils.py @@ -149,7 +149,7 @@ def rootWindow(): return window -def launchDialog(parent, dialogClass, instance, modal=True, instanced=True): +def launchDialog(parent, dialogClass, instance, modal=True, instanced=True, **kwargs): # if instanced: # if instance is None: # dlg = dialogClass(parent=parent) @@ -157,7 +157,7 @@ def launchDialog(parent, dialogClass, instance, modal=True, instanced=True): # dlg = instance # else: # dlg = dialogClass(parent=parent) - dlg = dialogClass(parent=parent) + dlg = dialogClass(parent=parent, **kwargs) if modal: dlg.exec_()