From 44fa1df170afacce00959ce595f059317f4ee946 Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 1 Apr 2024 17:25:32 -0700 Subject: [PATCH 01/27] init deformers module with Wrap methods --- GETOOLS_SOURCE/modules/GeneralWindow.py | 6 ++- GETOOLS_SOURCE/modules/Rigging.py | 2 +- GETOOLS_SOURCE/utils/Deformers.py | 69 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 GETOOLS_SOURCE/utils/Deformers.py diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 0b63487..177a5ed 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -32,6 +32,7 @@ from ..modules import Tools from ..utils import Colors +from ..utils import Deformers from ..utils import Install from ..utils import Layers from ..utils import MayaSettings @@ -42,7 +43,7 @@ from ..values import Icons class GeneralWindow: - version = "v1.0.4" + version = "v1.0.5" name = "GETools" title = name + " " + version @@ -109,6 +110,9 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(label = "Print channel box selected attributes", command = PrintChannelBoxAttributes, image = Icons.text) cmds.menuItem(divider = True) cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) + cmds.menuItem(divider = True) + cmds.menuItem(label = "Wraps Create", command = Deformers.WrapsCreate) # TODO finish wraps logic and move to Rigging module + cmds.menuItem(label = "Wraps Delete", command = Deformers.WrapsDelete) # TODO finish wraps logic and move to Rigging module self.LayoutMenuInstall() diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index 6ad4666..8483689 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -60,7 +60,7 @@ class RiggingAnnotations: copySkinWeights = "Copy skin weights from last selected object to all other selected objects" class Rigging: - version = "v1.0" + version = "v1.1" name = "RIGGING" title = name + " " + version diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py new file mode 100644 index 0000000..5b8ad10 --- /dev/null +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -0,0 +1,69 @@ +# GETOOLS is under the terms of the MIT License + +# Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene + +import maya.cmds as cmds +# import maya.mel as mel + +from ..utils import Selector +from ..values import Enums + + +NameWrap = "wrapTemp" + + +def WrapsCreate(*args): + # Check selected objects + selectedList = Selector.MultipleObjects(2) + if (selectedList == None): + return + + cmds.select(clear = True) + + wrapList = [] + + for i in range(len(selectedList)): + if(i >= len(selectedList) - 1): + break + + targetShape = selectedList[i] + Enums.Types.shape + sourceShape = selectedList[-1] + Enums.Types.shape + sourceTransform = selectedList[-1] + + # Create wrap node and connect + node = cmds.deformer(targetShape, name = NameWrap, type = "wrap") + wrapList.append(node) + cmds.connectAttr(NameWrap + ".input[0].inputGeometry", NameWrap + ".basePoints[0]") + cmds.connectAttr(sourceShape + ".worldMesh[0]", NameWrap + ".driverPoints[0]") + cmds.connectAttr(sourceTransform + ".inflType", NameWrap + ".inflType[0]") + + # Cleanup + cmds.select(selectedList, replace = True) + + return wrapList + +def WrapsDelete(wrapList, *args): # TODO + for item in wrapList: + cmds.disconnectAttr(item + ".input[0].inputGeometry", item + ".basePoints[0]") + cmds.delete(item) + From ccb6d14dec91289fc47c3703b7682b9b1b7e3860 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 2 Apr 2024 13:01:37 -0700 Subject: [PATCH 02/27] update wraps logic --- GETOOLS_SOURCE/modules/GeneralWindow.py | 4 +- GETOOLS_SOURCE/utils/Deformers.py | 63 ++++++++++++++++++------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 177a5ed..718c0ec 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -111,8 +111,8 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(divider = True) cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) cmds.menuItem(divider = True) - cmds.menuItem(label = "Wraps Create", command = Deformers.WrapsCreate) # TODO finish wraps logic and move to Rigging module - cmds.menuItem(label = "Wraps Delete", command = Deformers.WrapsDelete) # TODO finish wraps logic and move to Rigging module + cmds.menuItem(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected) # TODO finish wraps logic and move to Rigging module + cmds.menuItem(label = "Blendshapes Wrap Migrate", command = Deformers.BlendshapesWrapMigrate) # TODO finish wraps logic and move to Rigging module self.LayoutMenuInstall() diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index 5b8ad10..bb876e6 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -32,23 +32,16 @@ NameWrap = "wrapTemp" -def WrapsCreate(*args): - # Check selected objects - selectedList = Selector.MultipleObjects(2) - if (selectedList == None): - return - - cmds.select(clear = True) - +def WrapsCreate(elements, *args): wrapList = [] - for i in range(len(selectedList)): - if(i >= len(selectedList) - 1): + for i in range(len(elements)): + if (i >= len(elements) - 1): break - targetShape = selectedList[i] + Enums.Types.shape - sourceShape = selectedList[-1] + Enums.Types.shape - sourceTransform = selectedList[-1] + targetShape = elements[i] + Enums.Types.shape + sourceShape = elements[-1] + Enums.Types.shape + sourceTransform = elements[-1] # Create wrap node and connect node = cmds.deformer(targetShape, name = NameWrap, type = "wrap") @@ -57,13 +50,51 @@ def WrapsCreate(*args): cmds.connectAttr(sourceShape + ".worldMesh[0]", NameWrap + ".driverPoints[0]") cmds.connectAttr(sourceTransform + ".inflType", NameWrap + ".inflType[0]") - # Cleanup + return wrapList +def WrapsCreateOnSelected(*args): + # Check selected objects + selectedList = Selector.MultipleObjects(2) + if (selectedList == None): + return + + cmds.select(clear = True) + wraps = WrapsCreate(selectedList) cmds.select(selectedList, replace = True) - return wrapList + return selectedList, wraps -def WrapsDelete(wrapList, *args): # TODO +def WrapsDelete(wrapList, *args): for item in wrapList: cmds.disconnectAttr(item + ".input[0].inputGeometry", item + ".basePoints[0]") cmds.delete(item) +def BlendshapesWrapMigrate(*args): # TODO + result = WrapsCreateOnSelected() + if (result == None): + cmds.warning("No objects detected") + return + + selectedList = result[0] + wraps = result[1] + + # TODO get original blendshape node + #blendshape = selectedList[-1] + # TODO get blenshaoe weights names + #weights = cmds.listAttr(blendshape + ".weight", multi = True) + + # TODO set blendshape to 1 + # TODO duplicate mesh + # TODO set blendshape to 0 + # TODO repeat + # for item in selectedList: + # print(len(weights)) + # for i in range(len(weights)): + # weights[i] + # pass + + # TODO connect new blendshapes to targets + + # TODO delete temporary wraps + # WrapsDelete(wraps) + pass + From 25ee68b99bea5c7c9a41e77f363b49618575cc98 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 3 Apr 2024 15:24:16 -0700 Subject: [PATCH 03/27] update blendshapes projecting logic --- GETOOLS_SOURCE/modules/GeneralWindow.py | 2 +- GETOOLS_SOURCE/utils/Deformers.py | 101 +++++++++++++++--------- 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 718c0ec..21d9c8d 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -112,7 +112,7 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) cmds.menuItem(divider = True) cmds.menuItem(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected) # TODO finish wraps logic and move to Rigging module - cmds.menuItem(label = "Blendshapes Wrap Migrate", command = Deformers.BlendshapesWrapMigrate) # TODO finish wraps logic and move to Rigging module + cmds.menuItem(label = "Blendshapes Wrap Migrate", command = Deformers.BlendshapesProjecting) # TODO finish wraps logic and move to Rigging module self.LayoutMenuInstall() diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index bb876e6..f7a9139 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -26,31 +26,47 @@ # import maya.mel as mel from ..utils import Selector -from ..values import Enums +# from ..values import Enums -NameWrap = "wrapTemp" +nameWrap = "wrapTemp" +dropoff = 4 +smoothness = 0 def WrapsCreate(elements, *args): - wrapList = [] + if (len(elements) < 2): + cmds.warning("Need at least 2 objects for Wrap") + return + + wrapsList = [] + sourceDuplicate = cmds.duplicate(elements[-1], name = elements[-1] + "Wrap") for i in range(len(elements)): if (i >= len(elements) - 1): break - targetShape = elements[i] + Enums.Types.shape - sourceShape = elements[-1] + Enums.Types.shape sourceTransform = elements[-1] - - # Create wrap node and connect - node = cmds.deformer(targetShape, name = NameWrap, type = "wrap") - wrapList.append(node) - cmds.connectAttr(NameWrap + ".input[0].inputGeometry", NameWrap + ".basePoints[0]") - cmds.connectAttr(sourceShape + ".worldMesh[0]", NameWrap + ".driverPoints[0]") - cmds.connectAttr(sourceTransform + ".inflType", NameWrap + ".inflType[0]") - - return wrapList + sourceDuplicateShape = cmds.listRelatives(sourceDuplicate, shapes = True, noIntermediate = True)[0] + sourceShape = cmds.listRelatives(elements[-1], shapes = True, noIntermediate = True)[0] + targetShape = cmds.listRelatives(elements[i], shapes = True, noIntermediate = True)[0] + + # Create wrap node + node = cmds.deformer(targetShape, name = nameWrap, type = "wrap")[0] + wrapsList.append(node) + + # Set wrap parameters + cmds.setAttr(node + ".falloffMode", 1) + cmds.setAttr(node + ".autoWeightThreshold", 1) + cmds.setAttr(node + ".dropoff[0]", dropoff) + cmds.setAttr(node + ".smoothness[0]", smoothness) + + # Connect to other nodes + cmds.connectAttr(sourceDuplicateShape + ".worldMesh[0]", node + ".basePoints[0]") + cmds.connectAttr(sourceShape + ".worldMesh[0]", node + ".driverPoints[0]") + cmds.connectAttr(sourceTransform + ".inflType", node + ".inflType[0]") + + return wrapsList, sourceDuplicate def WrapsCreateOnSelected(*args): # Check selected objects selectedList = Selector.MultipleObjects(2) @@ -61,40 +77,51 @@ def WrapsCreateOnSelected(*args): wraps = WrapsCreate(selectedList) cmds.select(selectedList, replace = True) - return selectedList, wraps + return selectedList, wraps[0], wraps[1] -def WrapsDelete(wrapList, *args): - for item in wrapList: - cmds.disconnectAttr(item + ".input[0].inputGeometry", item + ".basePoints[0]") - cmds.delete(item) +def WrapsDelete(wrapsList, *args): + for wrap in wrapsList: + cmds.delete(wrap) -def BlendshapesWrapMigrate(*args): # TODO +def BlendshapesProjecting(*args): # TODO result = WrapsCreateOnSelected() if (result == None): cmds.warning("No objects detected") return + cmds.select(clear = True) + + # Map values selectedList = result[0] + sourceMesh = selectedList[-1] wraps = result[1] + sourceDuplicate = result[2] + + # Get blendshape node and weights + shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # weak solution, what if index is not always the same? + blendshape = cmds.listConnections(shape, type = "blendShape")[0] + weights = cmds.listAttr(blendshape + ".weight", multi = True) - # TODO get original blendshape node - #blendshape = selectedList[-1] - # TODO get blenshaoe weights names - #weights = cmds.listAttr(blendshape + ".weight", multi = True) - - # TODO set blendshape to 1 - # TODO duplicate mesh - # TODO set blendshape to 0 - # TODO repeat - # for item in selectedList: - # print(len(weights)) - # for i in range(len(weights)): - # weights[i] - # pass + # Zero all weights + for item in weights: + cmds.setAttr(blendshape + "." + item, 0) + + # Activate one by one and duplicate results + duplicatesList = [] + for i in range(len(selectedList) - 1): + duplicates = [] + for item in weights: + cmds.setAttr(blendshape + "." + item, 1) + duplicate = cmds.duplicate(selectedList[i], name = item) + duplicates.append(duplicate) + cmds.setAttr(blendshape + "." + item, 0) + duplicatesList.append(duplicates) + # TODO create blendshape nodes to targets # TODO connect new blendshapes to targets - # TODO delete temporary wraps - # WrapsDelete(wraps) - pass + WrapsDelete(wraps) + cmds.delete(sourceDuplicate) + + cmds.select(selectedList, replace = True) From deb2a6dc13c17e069e230c939c54f78196267612 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 5 Apr 2024 11:23:35 -0700 Subject: [PATCH 04/27] complete core logic for blendshapes projecting --- GETOOLS_SOURCE/utils/Deformers.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index f7a9139..cf96695 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -28,8 +28,8 @@ from ..utils import Selector # from ..values import Enums - nameWrap = "wrapTemp" +nameBlendshapePrefix = "bs_" dropoff = 4 smoothness = 0 @@ -83,7 +83,7 @@ def WrapsDelete(wrapsList, *args): for wrap in wrapsList: cmds.delete(wrap) -def BlendshapesProjecting(*args): # TODO +def BlendshapesProjecting(*args): # TODO split function to steps result = WrapsCreateOnSelected() if (result == None): cmds.warning("No objects detected") @@ -99,29 +99,34 @@ def BlendshapesProjecting(*args): # TODO # Get blendshape node and weights shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # weak solution, what if index is not always the same? - blendshape = cmds.listConnections(shape, type = "blendShape")[0] - weights = cmds.listAttr(blendshape + ".weight", multi = True) + blendshapeSource = cmds.listConnections(shape, type = "blendShape")[0] + weights = cmds.listAttr(blendshapeSource + ".weight", multi = True) # Zero all weights for item in weights: - cmds.setAttr(blendshape + "." + item, 0) + cmds.setAttr(blendshapeSource + "." + item, 0) # Activate one by one and duplicate results duplicatesList = [] for i in range(len(selectedList) - 1): duplicates = [] for item in weights: - cmds.setAttr(blendshape + "." + item, 1) + cmds.setAttr(blendshapeSource + "." + item, 1) duplicate = cmds.duplicate(selectedList[i], name = item) duplicates.append(duplicate) - cmds.setAttr(blendshape + "." + item, 0) + cmds.setAttr(blendshapeSource + "." + item, 0) duplicatesList.append(duplicates) - - # TODO create blendshape nodes to targets - # TODO connect new blendshapes to targets - + + # Wraps cleanup WrapsDelete(wraps) cmds.delete(sourceDuplicate) + # Create blendshape nodes, add targets and delete duplicates + for x in range(len(selectedList) - 1): + blendshapeTarget = cmds.blendShape(selectedList[x], name = nameBlendshapePrefix + selectedList[x]) + for y in range(len(duplicatesList[x])): + cmds.blendShape(blendshapeTarget, edit = True, target = (selectedList[x], y, duplicatesList[x][y][0], 1.0)) + cmds.delete(duplicatesList[x][y][0]) + cmds.select(selectedList, replace = True) From 6daa45755467a16ec7f288f0a4e4e8621bba81de Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 5 Apr 2024 12:17:37 -0700 Subject: [PATCH 05/27] cleanup blendshape projection logic --- GETOOLS_SOURCE/modules/GeneralWindow.py | 27 ++++++++++++++----------- GETOOLS_SOURCE/modules/Rigging.py | 15 ++++++++++++++ GETOOLS_SOURCE/utils/Deformers.py | 23 ++++++++++++++++----- GETOOLS_SOURCE/utils/Install.py | 17 ++++++++++++++++ GETOOLS_SOURCE/values/Icons.py | 2 ++ 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 21d9c8d..6444f28 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -32,7 +32,6 @@ from ..modules import Tools from ..utils import Colors -from ..utils import Deformers from ..utils import Install from ..utils import Layers from ..utils import MayaSettings @@ -110,9 +109,6 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(label = "Print channel box selected attributes", command = PrintChannelBoxAttributes, image = Icons.text) cmds.menuItem(divider = True) cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) - cmds.menuItem(divider = True) - cmds.menuItem(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected) # TODO finish wraps logic and move to Rigging module - cmds.menuItem(label = "Blendshapes Wrap Migrate", command = Deformers.BlendshapesProjecting) # TODO finish wraps logic and move to Rigging module self.LayoutMenuInstall() @@ -181,9 +177,9 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Exit Maya (force)", command = partial(Install.ToShelf_ExitMaya, self.directory)) cmds.menuItem(dividerLabel = "Utils", divider = True) cmds.menuItem(label = "Select Hiererchy", command = partial(Install.ToShelf_SelectHierarchy, self.directory)) - cmds.menuItem(label = "Create Reset Button", command = partial(Install.ToShelf_CreateResetButton, self.directory), image = Icons.reset) + # cmds.menuItem(label = "Create Reset Button", command = partial(Install.ToShelf_CreateResetButton, self.directory), image = Icons.reset) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "TOOLS - Locators", divider = True) ### cmds.menuItem(subMenu = True, label = "Size") @@ -244,7 +240,7 @@ def LayoutMenuInstall(self): cmds.menuItem(label = axisZMinus, command = partial(Install.ToShelf_LocatorsAim, self.directory, axisZMinus, True, (0, 0, -1))) cmds.menuItem(label = axisZPlus, command = partial(Install.ToShelf_LocatorsAim, self.directory, axisZPlus, True, (0, 0, 1))) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "TOOLS - Baking", divider = True) ### cmds.menuItem(subMenu = True, label = "Bake") @@ -266,7 +262,7 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "POS", command = partial(Install.ToShelf_BakeByWorld, self.directory, True, False)) cmds.menuItem(label = "ROT", command = partial(Install.ToShelf_BakeByWorld, self.directory, False, True)) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "TOOLS - Animation", divider = True) ### cmds.menuItem(subMenu = True, label = "Delete", image = Icons.delete) @@ -296,7 +292,7 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "+2", command = partial(Install.ToShelf_AnimOffset, self.directory, 1, 2)) cmds.menuItem(label = "+3", command = partial(Install.ToShelf_AnimOffset, self.directory, 1, 3)) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "TOOLS - Timeline", divider = True) ### cmds.menuItem(subMenu = True, label = "Timeline") @@ -311,7 +307,7 @@ def LayoutMenuInstall(self): cmds.menuItem(divider = True) cmds.menuItem(label = "Selected Range", command = partial(Install.ToShelf_SetTimelineSet, self.directory)) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "RIGGING - Constraints", divider = True) ### cmds.menuItem(subMenu = True, label = "Constraints", image = Icons.constraint) @@ -330,7 +326,7 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Disconnect", command = partial(Install.ToShelf_DisconnectTargets, self.directory)) cmds.menuItem(label = "Delete Constraints", command = partial(Install.ToShelf_DeleteConstraints, self.directory)) cmds.setParent('..', menu = True) - # + cmds.menuItem(dividerLabel = "RIGGING - Utils", divider = True) ### cmds.menuItem(subMenu = True, label = "Rotate Order") @@ -349,7 +345,14 @@ def LayoutMenuInstall(self): cmds.setParent('..', menu = True) # cmds.menuItem(label = "Copy Skin Weights From Last Selected", command = partial(Install.ToShelf_CopySkin, self.directory), image = Icons.copy) - # + + cmds.menuItem(dividerLabel = "RIGGING - Deformers", divider = True) + ### + # cmds.menuItem(subMenu = True, label = "Rotate Order") + cmds.menuItem(label = "Wraps Create", command = partial(Install.ToShelf_WrapsCreate, self.directory), image = Icons.wrap) + cmds.menuItem(label = "Blendshapes Projecting", command = partial(Install.ToShelf_BlendshapesProjecting, self.directory), image = Icons.blendshape) + cmds.setParent('..', menu = True) + cmds.menuItem(dividerLabel = "EXPERIMENTAL", divider = True) ### cmds.menuItem(subMenu = True, label = "Motion Trail") diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index 8483689..9004ea5 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -29,6 +29,7 @@ from ..utils import Colors from ..utils import Constraints +from ..utils import Deformers from ..utils import Other from ..utils import Skinning from ..utils import UI @@ -59,6 +60,10 @@ class RiggingAnnotations: jointDrawStyleHidden = "Hidden {0}".format(_jointDrawStyle) copySkinWeights = "Copy skin weights from last selected object to all other selected objects" + # Deformers + wraps = "Create wrap deformer on selected objects. Last object used as source deformation object." + blendshapeProjection = "Copy blendshapes from last selected object that must have a blendshape node" + class Rigging: version = "v1.1" name = "RIGGING" @@ -115,6 +120,16 @@ def UICreate(self, layoutMain): countOffsets = 1 cmds.gridLayout(parent = layoutColumnUtils, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) cmds.button(label = "Copy Skin Weights From Last Selected", command = Skinning.CopySkinWeightsFromLastMesh, backgroundColor = Colors.blue10, annotation = RiggingAnnotations.copySkinWeights) + + + # DEFORMERS + layoutBlendshapes = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "DEFORMERS", collapsable = True, backgroundColor = Settings.frames2Color) + layoutColumnBlendshapes = cmds.columnLayout(parent = layoutBlendshapes, adjustableColumn = True) + # + countOffsets = 2 + cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) + cmds.button(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.wraps) + cmds.button(label = "Blendshapes Projecting", command = Deformers.BlendshapesProjecting, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeProjection) # CONSTRAINTS diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index cf96695..c122ece 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -60,11 +60,12 @@ def WrapsCreate(elements, *args): cmds.setAttr(node + ".autoWeightThreshold", 1) cmds.setAttr(node + ".dropoff[0]", dropoff) cmds.setAttr(node + ".smoothness[0]", smoothness) + cmds.setAttr(node + ".inflType[0]", 2) # Connect to other nodes cmds.connectAttr(sourceDuplicateShape + ".worldMesh[0]", node + ".basePoints[0]") cmds.connectAttr(sourceShape + ".worldMesh[0]", node + ".driverPoints[0]") - cmds.connectAttr(sourceTransform + ".inflType", node + ".inflType[0]") + # cmds.connectAttr(sourceTransform + ".inflType", node + ".inflType[0]") return wrapsList, sourceDuplicate def WrapsCreateOnSelected(*args): @@ -83,7 +84,7 @@ def WrapsDelete(wrapsList, *args): for wrap in wrapsList: cmds.delete(wrap) -def BlendshapesProjecting(*args): # TODO split function to steps +def BlendshapesProjecting(*args): result = WrapsCreateOnSelected() if (result == None): cmds.warning("No objects detected") @@ -97,9 +98,21 @@ def BlendshapesProjecting(*args): # TODO split function to steps wraps = result[1] sourceDuplicate = result[2] - # Get blendshape node and weights - shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # weak solution, what if index is not always the same? - blendshapeSource = cmds.listConnections(shape, type = "blendShape")[0] + # Get blendshape node + # print("### {0}".format(cmds.listRelatives(sourceMesh, shapes = True))) # HACK for debug shape issue + shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # FIXME weak solution, index is not always the same and sometimes just 1 element + blendshapeSource = cmds.listConnections(shape, type = "blendShape") + + # Check blendshape node + if (blendshapeSource == None): + cmds.warning("Last selected object has no blendShape node. Operation aborted") + WrapsDelete(wraps) + cmds.delete(sourceDuplicate) + cmds.select(selectedList, replace = True) + return + + # Get blendshape weights + blendshapeSource = blendshapeSource[0] weights = cmds.listAttr(blendshapeSource + ".weight", multi = True) # Zero all weights diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 7b9d9c3..0cd4dc3 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -43,6 +43,8 @@ class Presets: # TODO simplify "import GETOOLS_SOURCE.utils.Selector as selector" pathOther =\ "import GETOOLS_SOURCE.utils.Other as other" + pathDeformers =\ + "import GETOOLS_SOURCE.utils.Deformers as deformers" pathConstraints =\ "import GETOOLS_SOURCE.utils.Constraints as constraints" pathLocators =\ @@ -250,6 +252,16 @@ class Presets: # TODO simplify skinning.CopySkinWeightsFromLastMesh()\ '''.format(pathSkinning) + runWrapsCreate ='''\ +{0} +deformers.WrapsCreateOnSelected()\ +'''.format(pathDeformers) + + runBlendshapesProjecting ='''\ +{0} +deformers.BlendshapesProjecting()\ +'''.format(pathDeformers) + # EXPERIMENTAL runMotionTrailCreate ='''\ @@ -452,6 +464,11 @@ def ToShelf_JointDrawStyle(path, mode, *args): def ToShelf_CopySkin(path, *args): MoveToShelf(path, Presets.runCopySkin, "CopySkin", "CopySkin") +def ToShelf_WrapsCreate(path, *args): + MoveToShelf(path, Presets.runWrapsCreate, "WrapsCreate", "WrapsCreate") +def ToShelf_BlendshapesProjecting(path, *args): + MoveToShelf(path, Presets.runBlendshapesProjecting, "BSProjecting", "BSProjecting") + # MOTION TRAIL def ToShelf_MotionTrailCreate(path, *args): diff --git a/GETOOLS_SOURCE/values/Icons.py b/GETOOLS_SOURCE/values/Icons.py index 545eb1c..d95f2c9 100644 --- a/GETOOLS_SOURCE/values/Icons.py +++ b/GETOOLS_SOURCE/values/Icons.py @@ -80,6 +80,8 @@ warning = "warningIcon.svg" world = "volumeSphere.png" zoom = "zoom.png" +blendshape = "blendShape.png" +wrap = "wrap.png" # TODO add icons sample window From e3b791769b110affbd056858cf5f39ac75cfebe0 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 26 Apr 2024 10:09:32 -0700 Subject: [PATCH 06/27] save --- GETOOLS_SOURCE/modules/Rigging.py | 2 +- GETOOLS_SOURCE/utils/Deformers.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index 9004ea5..072166e 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -129,7 +129,7 @@ def UICreate(self, layoutMain): countOffsets = 2 cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) cmds.button(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.wraps) - cmds.button(label = "Blendshapes Projecting", command = Deformers.BlendshapesProjecting, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeProjection) + cmds.button(label = "Blendshapes Projecting", command = Deformers.BlendshapesExtraction, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeProjection) # CONSTRAINTS diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index c122ece..032f347 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -84,7 +84,7 @@ def WrapsDelete(wrapsList, *args): for wrap in wrapsList: cmds.delete(wrap) -def BlendshapesProjecting(*args): +def BlendshapesExtraction(*args): # TODO separate from Wraps logic result = WrapsCreateOnSelected() if (result == None): cmds.warning("No objects detected") @@ -143,3 +143,7 @@ def BlendshapesProjecting(*args): cmds.select(selectedList, replace = True) +def RunBlendshapesLogic(*args): # TODO combine wraps and blendshapes logic + result = WrapsCreateOnSelected() + BlendshapesExtraction() + From ae3114c98b0eabce0ccc437e4e328db741b9ba37 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 26 Jun 2024 13:23:06 -0700 Subject: [PATCH 07/27] save: - moved blendshapes logic to separate script - added 3 new buttons: - "Print Blendshapes Base Nodes" - "Print Blendshapes Names" - "Zero Blendshapes Weights" --- GETOOLS_SOURCE/modules/GeneralWindow.py | 4 + GETOOLS_SOURCE/modules/Rigging.py | 16 +++- GETOOLS_SOURCE/utils/Blendshapes.py | 111 ++++++++++++++++++++++++ GETOOLS_SOURCE/utils/Deformers.py | 3 +- GETOOLS_SOURCE/utils/Selector.py | 6 +- 5 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 GETOOLS_SOURCE/utils/Blendshapes.py diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 6444f28..6f98b38 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -31,6 +31,7 @@ from ..modules import Settings from ..modules import Tools +from ..utils import Blendshapes from ..utils import Colors from ..utils import Install from ..utils import Layers @@ -109,6 +110,9 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(label = "Print channel box selected attributes", command = PrintChannelBoxAttributes, image = Icons.text) cmds.menuItem(divider = True) cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) + cmds.menuItem(dividerLabel = "Blendshapes", divider = True) + cmds.menuItem(label = "Print Blendshapes Base Nodes", command = Blendshapes.GetBlendshapeNodesFromSelected, image = Icons.text) + cmds.menuItem(label = "Print Blendshapes Names", command = Blendshapes.GetBlendshapeWeightsFromSelected, image = Icons.text) self.LayoutMenuInstall() diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index 072166e..e143ab1 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -27,6 +27,7 @@ from ..modules import Settings +from ..utils import Blendshapes from ..utils import Colors from ..utils import Constraints from ..utils import Deformers @@ -123,13 +124,22 @@ def UICreate(self, layoutMain): # DEFORMERS - layoutBlendshapes = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "DEFORMERS", collapsable = True, backgroundColor = Settings.frames2Color) - layoutColumnBlendshapes = cmds.columnLayout(parent = layoutBlendshapes, adjustableColumn = True) + layoutDeformers = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "DEFORMERS", collapsable = True, backgroundColor = Settings.frames2Color) + layoutColumnDeformers = cmds.columnLayout(parent = layoutDeformers, adjustableColumn = True) # countOffsets = 2 - cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) + cmds.gridLayout(parent = layoutColumnDeformers, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) cmds.button(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.wraps) cmds.button(label = "Blendshapes Projecting", command = Deformers.BlendshapesExtraction, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeProjection) + + + # BLENDSHAPES + layoutBlendshapes = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "BLENDSHAPES", collapsable = True, backgroundColor = Settings.frames2Color) + layoutColumnBlendshapes = cmds.columnLayout(parent = layoutBlendshapes, adjustableColumn = True) + # + countOffsets = 1 + cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) + cmds.button(label = "Zero Blendshapes Weights", command = Blendshapes.ZeroBlendshapeWeightsOnSelected) # CONSTRAINTS diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py new file mode 100644 index 0000000..f46270d --- /dev/null +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -0,0 +1,111 @@ +# GETOOLS is under the terms of the MIT License + +# Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene + +import maya.cmds as cmds +# import maya.mel as mel + +from ..utils import Selector + + +def GetBlendshapeNodesFromList(selectedList): + if (selectedList == None): + return None + + result = [] + + # Get blendshape nodes + for element in selectedList: + relatives = cmds.listRelatives(element) + blendshapes = [] + + for relative in relatives: + connections = cmds.listConnections(relative, type = "blendShape") + if (connections == None): + continue + + for connection in connections: + if connection not in blendshapes: + blendshapes.append(connection) + + result.append(blendshapes) + + # Print result + print("\tBLENDSHAPES")# + for item in result: + if (len(item) == 0): + continue + print(item[0])# + + return result +def GetBlendshapeNodesFromSelected(*args): + # Check selected objects + selectedList = Selector.MultipleObjects(1) + if (selectedList == None): + return None + + return GetBlendshapeNodesFromList(selectedList) + +def GetBlendshapeWeights(blendshape): + # Check blendshape node + if (blendshape == None or len(blendshape) == 0): + return None + + # Get blendshape weights + blendshapeNode = blendshape[0] + weights = cmds.listAttr(blendshapeNode + ".weight", multi = True) + + result = [] + + # Print result + print("\tBLENDSHAPE \"{0}\" WEIGHTS".format(blendshape[0]))# + for weight in weights: + result.append(blendshapeNode + "." + weight) + print(result[-1])# + + return result +def GetBlendshapeWeightsFromSelected(*args): + blendshapes = GetBlendshapeNodesFromSelected() + if (blendshapes == None): + return None + + result = [] + + for blendshape in blendshapes: + result.append(GetBlendshapeWeights(blendshape)) + + return result + +def ZeroBlendshapeWeights(weights): + for weight in weights: + cmds.setAttr(weight, 0) +def ZeroBlendshapeWeightsOnSelected(*args): + weights = GetBlendshapeWeightsFromSelected() + if (weights == None): + return + + for item in weights: + if (item == None): + continue + ZeroBlendshapeWeights(item) + diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index 032f347..eacaf06 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -99,8 +99,7 @@ def BlendshapesExtraction(*args): # TODO separate from Wraps logic sourceDuplicate = result[2] # Get blendshape node - # print("### {0}".format(cmds.listRelatives(sourceMesh, shapes = True))) # HACK for debug shape issue - shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # FIXME weak solution, index is not always the same and sometimes just 1 element + shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # FIXME replace by new Blendshapes methods blendshapeSource = cmds.listConnections(shape, type = "blendShape") # Check blendshape node diff --git a/GETOOLS_SOURCE/utils/Selector.py b/GETOOLS_SOURCE/utils/Selector.py index 10acd61..631549f 100644 --- a/GETOOLS_SOURCE/utils/Selector.py +++ b/GETOOLS_SOURCE/utils/Selector.py @@ -24,12 +24,12 @@ import maya.cmds as cmds -def MultipleObjects(minimalCount=1, transformsOnly=True): +def MultipleObjects(minimalCount=1, transformsOnly=True, shapes=False): # Save selected objects to variable if (transformsOnly): - selectedList = cmds.ls(selection = True, type = "transform", shapes = False) + selectedList = cmds.ls(selection = True, type = "transform", shapes = shapes) else: - selectedList = cmds.ls(selection = True, shapes = False) + selectedList = cmds.ls(selection = True, shapes = shapes) # Check selected objects if (len(selectedList) < minimalCount): From 96f77d24e4979ea1da7a11b13154ae40c2bda130 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 26 Jun 2024 14:53:41 -0700 Subject: [PATCH 08/27] update Blendshapes logic, fix projecting --- GETOOLS_SOURCE/utils/Blendshapes.py | 72 ++++++++++++++++------------- GETOOLS_SOURCE/utils/Deformers.py | 63 +++++++++++++------------ 2 files changed, 71 insertions(+), 64 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index f46270d..1ca9a14 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -28,34 +28,40 @@ from ..utils import Selector -def GetBlendshapeNodesFromList(selectedList): - if (selectedList == None): +def GetBlendshapeNodeFromModel(model): + if (model == None): return None - result = [] + result = "" # Get blendshape nodes - for element in selectedList: - relatives = cmds.listRelatives(element) - blendshapes = [] + relatives = cmds.listRelatives(model) + blendshapes = [] - for relative in relatives: - connections = cmds.listConnections(relative, type = "blendShape") - if (connections == None): - continue + for relative in relatives: + connections = cmds.listConnections(relative, type = "blendShape") + if (connections == None): + continue - for connection in connections: - if connection not in blendshapes: - blendshapes.append(connection) + for connection in connections: + if connection not in blendshapes: + result = connection - result.append(blendshapes) + if (len(result) == 0): + return None - # Print result + print(result)# + return result +def GetBlendshapeNodesFromModelList(modelList): + if (modelList == None): + return None + + result = [] + + # Get blendshape nodes print("\tBLENDSHAPES")# - for item in result: - if (len(item) == 0): - continue - print(item[0])# + for model in modelList: + result.append(GetBlendshapeNodeFromModel(model)) return result def GetBlendshapeNodesFromSelected(*args): @@ -64,7 +70,7 @@ def GetBlendshapeNodesFromSelected(*args): if (selectedList == None): return None - return GetBlendshapeNodesFromList(selectedList) + return GetBlendshapeNodesFromModelList(selectedList) def GetBlendshapeWeights(blendshape): # Check blendshape node @@ -72,35 +78,37 @@ def GetBlendshapeWeights(blendshape): return None # Get blendshape weights - blendshapeNode = blendshape[0] - weights = cmds.listAttr(blendshapeNode + ".weight", multi = True) + blendshapeNode = blendshape + weightsNames = cmds.listAttr(blendshapeNode + ".weight", multi = True) - result = [] + weightsNamesFull = [] # Print result - print("\tBLENDSHAPE \"{0}\" WEIGHTS".format(blendshape[0]))# - for weight in weights: - result.append(blendshapeNode + "." + weight) - print(result[-1])# + print("\tBLENDSHAPE \"{0}\" WEIGHTS".format(blendshape))# + for weight in weightsNames: + weightsNamesFull.append(blendshapeNode + "." + weight) + print(weightsNamesFull[-1])# - return result + return weightsNamesFull, weightsNames def GetBlendshapeWeightsFromSelected(*args): blendshapes = GetBlendshapeNodesFromSelected() if (blendshapes == None): return None - result = [] + weightsNamesFull = [] + weightsNames = [] for blendshape in blendshapes: - result.append(GetBlendshapeWeights(blendshape)) + weightsNamesFull.append(GetBlendshapeWeights(blendshape)[0]) + weightsNames.append(GetBlendshapeWeights(blendshape)[1]) - return result + return weightsNamesFull, weightsNames def ZeroBlendshapeWeights(weights): for weight in weights: cmds.setAttr(weight, 0) def ZeroBlendshapeWeightsOnSelected(*args): - weights = GetBlendshapeWeightsFromSelected() + weights = GetBlendshapeWeightsFromSelected()[0] if (weights == None): return diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index eacaf06..d77ed6f 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -25,6 +25,7 @@ import maya.cmds as cmds # import maya.mel as mel +from ..utils import Blendshapes from ..utils import Selector # from ..values import Enums @@ -34,7 +35,7 @@ smoothness = 0 -def WrapsCreate(elements, *args): +def WrapsCreate(elements): if (len(elements) < 2): cmds.warning("Need at least 2 objects for Wrap") return @@ -80,11 +81,26 @@ def WrapsCreateOnSelected(*args): return selectedList, wraps[0], wraps[1] -def WrapsDelete(wrapsList, *args): - for wrap in wrapsList: +def WrapsDelete(wraps): + for wrap in wraps: cmds.delete(wrap) -def BlendshapesExtraction(*args): # TODO separate from Wraps logic +def BlendshapesExtraction(*args): + # Check selected objects + selectedList = Selector.MultipleObjects(2) + if (selectedList == None): + return + + # Get blendshape node + sourceMesh = selectedList[-1] + blendshapeSource = Blendshapes.GetBlendshapeNodeFromModel(sourceMesh) + + # Check blendshape node + if (blendshapeSource == None): + cmds.warning("Last selected object has no blendShape node. Operation aborted") + return + + # Create wraps result = WrapsCreateOnSelected() if (result == None): cmds.warning("No objects detected") @@ -93,40 +109,22 @@ def BlendshapesExtraction(*args): # TODO separate from Wraps logic cmds.select(clear = True) # Map values - selectedList = result[0] - sourceMesh = selectedList[-1] wraps = result[1] sourceDuplicate = result[2] - # Get blendshape node - shape = cmds.listRelatives(sourceMesh, shapes = True)[1] # FIXME replace by new Blendshapes methods - blendshapeSource = cmds.listConnections(shape, type = "blendShape") - - # Check blendshape node - if (blendshapeSource == None): - cmds.warning("Last selected object has no blendShape node. Operation aborted") - WrapsDelete(wraps) - cmds.delete(sourceDuplicate) - cmds.select(selectedList, replace = True) - return - - # Get blendshape weights - blendshapeSource = blendshapeSource[0] - weights = cmds.listAttr(blendshapeSource + ".weight", multi = True) + # Get blendshape weights and zero all of them + weights = Blendshapes.GetBlendshapeWeights(blendshapeSource) + Blendshapes.ZeroBlendshapeWeights(weights[0]) - # Zero all weights - for item in weights: - cmds.setAttr(blendshapeSource + "." + item, 0) - # Activate one by one and duplicate results duplicatesList = [] for i in range(len(selectedList) - 1): duplicates = [] - for item in weights: - cmds.setAttr(blendshapeSource + "." + item, 1) - duplicate = cmds.duplicate(selectedList[i], name = item) + for y in range(len(weights[0])): + cmds.setAttr(weights[0][y], 1) + duplicate = cmds.duplicate(selectedList[i], name = weights[1][y]) duplicates.append(duplicate) - cmds.setAttr(blendshapeSource + "." + item, 0) + cmds.setAttr(weights[0][y], 0) duplicatesList.append(duplicates) # Wraps cleanup @@ -139,10 +137,11 @@ def BlendshapesExtraction(*args): # TODO separate from Wraps logic for y in range(len(duplicatesList[x])): cmds.blendShape(blendshapeTarget, edit = True, target = (selectedList[x], y, duplicatesList[x][y][0], 1.0)) cmds.delete(duplicatesList[x][y][0]) - + cmds.select(selectedList, replace = True) def RunBlendshapesLogic(*args): # TODO combine wraps and blendshapes logic - result = WrapsCreateOnSelected() - BlendshapesExtraction() + # result = WrapsCreateOnSelected() + # BlendshapesExtraction() + pass From 0d2b23d12c46923ebc169b3472bb5fa054462f5e Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 26 Jun 2024 14:58:08 -0700 Subject: [PATCH 09/27] fix --- GETOOLS_SOURCE/utils/Blendshapes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index 1ca9a14..dc0440c 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -99,8 +99,11 @@ def GetBlendshapeWeightsFromSelected(*args): weightsNames = [] for blendshape in blendshapes: - weightsNamesFull.append(GetBlendshapeWeights(blendshape)[0]) - weightsNames.append(GetBlendshapeWeights(blendshape)[1]) + weightsRaw = GetBlendshapeWeights(blendshape) + if(weightsRaw == None): + continue + weightsNamesFull.append(weightsRaw[0]) + weightsNames.append(weightsRaw[1]) return weightsNamesFull, weightsNames From 35d1fc760128e88bfe9695752159193811be9852 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 26 Jun 2024 14:58:29 -0700 Subject: [PATCH 10/27] Update Blendshapes.py --- GETOOLS_SOURCE/utils/Blendshapes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index dc0440c..5696a2c 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -100,7 +100,7 @@ def GetBlendshapeWeightsFromSelected(*args): for blendshape in blendshapes: weightsRaw = GetBlendshapeWeights(blendshape) - if(weightsRaw == None): + if (weightsRaw == None): continue weightsNamesFull.append(weightsRaw[0]) weightsNames.append(weightsRaw[1]) From eba65570f6e2911b2403390f6baa038120057025 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 26 Jun 2024 15:33:09 -0700 Subject: [PATCH 11/27] fix empty selected on blendshape zeroing --- GETOOLS_SOURCE/utils/Blendshapes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index 5696a2c..ced4513 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -111,11 +111,11 @@ def ZeroBlendshapeWeights(weights): for weight in weights: cmds.setAttr(weight, 0) def ZeroBlendshapeWeightsOnSelected(*args): - weights = GetBlendshapeWeightsFromSelected()[0] + weights = GetBlendshapeWeightsFromSelected() if (weights == None): return - for item in weights: + for item in weights[0]: if (item == None): continue ZeroBlendshapeWeights(item) From 501608ba797184065f8ac4154b69b0f31fd592f2 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 12:13:30 -0700 Subject: [PATCH 12/27] update blendshapes general logic --- GETOOLS_SOURCE/modules/GeneralWindow.py | 6 ++-- GETOOLS_SOURCE/modules/Rigging.py | 36 +++++++++++------------- GETOOLS_SOURCE/utils/Deformers.py | 37 +++++++++++++++++++------ GETOOLS_SOURCE/utils/Install.py | 24 +++++++++++++--- 4 files changed, 68 insertions(+), 35 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 6f98b38..bc79188 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -350,11 +350,13 @@ def LayoutMenuInstall(self): # cmds.menuItem(label = "Copy Skin Weights From Last Selected", command = partial(Install.ToShelf_CopySkin, self.directory), image = Icons.copy) - cmds.menuItem(dividerLabel = "RIGGING - Deformers", divider = True) + cmds.menuItem(dividerLabel = "RIGGING - Blendshapes", divider = True) ### # cmds.menuItem(subMenu = True, label = "Rotate Order") cmds.menuItem(label = "Wraps Create", command = partial(Install.ToShelf_WrapsCreate, self.directory), image = Icons.wrap) - cmds.menuItem(label = "Blendshapes Projecting", command = partial(Install.ToShelf_BlendshapesProjecting, self.directory), image = Icons.blendshape) + # cmds.menuItem(label = "Wraps Convert", command = partial(Install.ToShelf_WrapsCreate, self.directory), image = Icons.wrap) # TODO + cmds.menuItem(label = "Reconstruct", command = partial(Install.ToShelf_BlendshapesReconstruct, self.directory), image = Icons.blendshape) + cmds.menuItem(label = "Zero Weights", command = partial(Install.ToShelf_BlendshapesZeroWeights, self.directory), image = Icons.blendshape) cmds.setParent('..', menu = True) cmds.menuItem(dividerLabel = "EXPERIMENTAL", divider = True) diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index e143ab1..3d28e5a 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -62,8 +62,9 @@ class RiggingAnnotations: copySkinWeights = "Copy skin weights from last selected object to all other selected objects" # Deformers - wraps = "Create wrap deformer on selected objects. Last object used as source deformation object." - blendshapeProjection = "Copy blendshapes from last selected object that must have a blendshape node" + wrapsCreate = "Create a wrap deformer on selected objects.\nThe last object used as a source deformation object" + blendshapeCopyFromTarget = "Reconstruct blendshapes on selected objects from the last selected object.\nThe last object must have a blendshape node" + blendshapeZeroWeights = "Zero all blendshape weights on selected objects" class Rigging: version = "v1.1" @@ -88,7 +89,7 @@ def UICreate(self, layoutMain): cmds.separator(style = "none") self.checkboxConstraintReverse = UI.Checkbox(label = "Reverse", value = False, annotation = RiggingAnnotations.constraintReverse) self.checkboxConstraintMaintain = UI.Checkbox(label = "Maintain", value = False, annotation = RiggingAnnotations.constraintMaintain) - # self.checkboxConstraintOffset = UI.Checkbox(label = "Offset", value = False, annotation = RiggingAnnotations.constraintOffset) + # self.checkboxConstraintOffset = UI.Checkbox(label = "**Offset", value = False, annotation = RiggingAnnotations.constraintOffset) cmds.separator(style = "none") # countOffsets = 4 @@ -97,7 +98,7 @@ def UICreate(self, layoutMain): cmds.button(label = "Point", command = self.ConstrainPoint, backgroundColor = Colors.red10, annotation = RiggingAnnotations.constraintPoint) cmds.button(label = "Orient", command = self.ConstrainOrient, backgroundColor = Colors.red10, annotation = RiggingAnnotations.constraintOrient) cmds.button(label = "Scale", command = self.ConstrainScale, backgroundColor = Colors.red10, annotation = RiggingAnnotations.constraintScale) - # cmds.button(label = "Aim", command = self.ConstrainAim, backgroundColor = Colors.red10, annotation = RiggingAnnotations.constraintAim, enable = False) # TODO + # cmds.button(label = "**Aim", command = self.ConstrainAim, backgroundColor = Colors.red10, annotation = RiggingAnnotations.constraintAim, enable = False) # TODO # countOffsets = 2 cmds.gridLayout(parent = layoutColumnConstraints, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) @@ -113,33 +114,28 @@ def UICreate(self, layoutMain): cmds.gridLayout(parent = layoutColumnUtils, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) cmds.button(label = "Rotate Order - SHOW", command = partial(Other.RotateOrderVisibility, True), backgroundColor = Colors.green10, annotation = RiggingAnnotations.rotateOrderShow) cmds.button(label = "Rotate Order - HIDE", command = partial(Other.RotateOrderVisibility, False), backgroundColor = Colors.green10, annotation = RiggingAnnotations.rotateOrderHide) - cmds.button(label = "Compensate - ON", command = partial(Other.SegmentScaleCompensate, True), backgroundColor = Colors.yellow10, annotation = RiggingAnnotations.scaleCompensateOn) - cmds.button(label = "Compensate - OFF", command = partial(Other.SegmentScaleCompensate, False), backgroundColor = Colors.yellow10, annotation = RiggingAnnotations.scaleCompensateOff) - cmds.button(label = "Joint - BONE", command = partial(Other.JointDrawStyle, 0), backgroundColor = Colors.orange10, annotation = RiggingAnnotations.jointDrawStyleBone) - cmds.button(label = "Joint - HIDDEN", command = partial(Other.JointDrawStyle, 2), backgroundColor = Colors.orange10, annotation = RiggingAnnotations.jointDrawStyleHidden) + cmds.button(label = "Compensate - ON", command = partial(Other.SegmentScaleCompensate, True), backgroundColor = Colors.orange10, annotation = RiggingAnnotations.scaleCompensateOn) + cmds.button(label = "Compensate - OFF", command = partial(Other.SegmentScaleCompensate, False), backgroundColor = Colors.orange10, annotation = RiggingAnnotations.scaleCompensateOff) + cmds.button(label = "Joint - BONE", command = partial(Other.JointDrawStyle, 0), backgroundColor = Colors.yellow10, annotation = RiggingAnnotations.jointDrawStyleBone) + cmds.button(label = "Joint - HIDDEN", command = partial(Other.JointDrawStyle, 2), backgroundColor = Colors.yellow10, annotation = RiggingAnnotations.jointDrawStyleHidden) # countOffsets = 1 cmds.gridLayout(parent = layoutColumnUtils, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) cmds.button(label = "Copy Skin Weights From Last Selected", command = Skinning.CopySkinWeightsFromLastMesh, backgroundColor = Colors.blue10, annotation = RiggingAnnotations.copySkinWeights) - - # DEFORMERS - layoutDeformers = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "DEFORMERS", collapsable = True, backgroundColor = Settings.frames2Color) - layoutColumnDeformers = cmds.columnLayout(parent = layoutDeformers, adjustableColumn = True) - # - countOffsets = 2 - cmds.gridLayout(parent = layoutColumnDeformers, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) - cmds.button(label = "Wraps Create", command = Deformers.WrapsCreateOnSelected, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.wraps) - cmds.button(label = "Blendshapes Projecting", command = Deformers.BlendshapesExtraction, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeProjection) - - # BLENDSHAPES layoutBlendshapes = cmds.frameLayout(parent = layoutMain, label = Settings.frames2Prefix + "BLENDSHAPES", collapsable = True, backgroundColor = Settings.frames2Color) layoutColumnBlendshapes = cmds.columnLayout(parent = layoutBlendshapes, adjustableColumn = True) # + countOffsets = 2 + cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) + cmds.button(label = "Wraps", command = Deformers.WrapsCreateOnSelected, backgroundColor = Colors.yellow10, annotation = RiggingAnnotations.wrapsCreate) + # cmds.button(label = "**Convert", command = Deformers.WrapConvertToBlendshapes) # TODO + cmds.button(label = "Reconstruct", command = Deformers.BlendshapesReconstruction, backgroundColor = Colors.green50, annotation = RiggingAnnotations.blendshapeCopyFromTarget) + # countOffsets = 1 cmds.gridLayout(parent = layoutColumnBlendshapes, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight) - cmds.button(label = "Zero Blendshapes Weights", command = Blendshapes.ZeroBlendshapeWeightsOnSelected) + cmds.button(label = "Zero Weights", command = Blendshapes.ZeroBlendshapeWeightsOnSelected, backgroundColor = Colors.blackWhite100, annotation = RiggingAnnotations.blendshapeZeroWeights) # CONSTRAINTS diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index d77ed6f..6bed7c4 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -35,7 +35,7 @@ smoothness = 0 -def WrapsCreate(elements): +def WrapsCreateOnList(elements): if (len(elements) < 2): cmds.warning("Need at least 2 objects for Wrap") return @@ -47,7 +47,7 @@ def WrapsCreate(elements): if (i >= len(elements) - 1): break - sourceTransform = elements[-1] + # sourceTransform = elements[-1] sourceDuplicateShape = cmds.listRelatives(sourceDuplicate, shapes = True, noIntermediate = True)[0] sourceShape = cmds.listRelatives(elements[-1], shapes = True, noIntermediate = True)[0] targetShape = cmds.listRelatives(elements[i], shapes = True, noIntermediate = True)[0] @@ -76,16 +76,40 @@ def WrapsCreateOnSelected(*args): return cmds.select(clear = True) - wraps = WrapsCreate(selectedList) + wraps = WrapsCreateOnList(selectedList) cmds.select(selectedList, replace = True) return selectedList, wraps[0], wraps[1] +def WrapConvertToBlendshapes(blendshape): # TODO create single conversion logic from Wrap to Blendshapes + # Check selected objects + selectedList = Selector.MultipleObjects(1) + if (selectedList == None): + return + + # Get blendshape nodes + relatives = cmds.listRelatives(selectedList[0]) + wraps = [] + + for relative in relatives: + connections = cmds.listConnections(relative, type = "wrap") + if (connections == None): + continue + + for connection in connections: + if connection not in wraps: + wraps.append(connection) + + print(wraps) + +def WrapsConvertFromSelected(*args): # TODO + pass + def WrapsDelete(wraps): for wrap in wraps: cmds.delete(wrap) -def BlendshapesExtraction(*args): +def BlendshapesReconstruction(*args): # TODO simplify function, split to smaller blocks # Check selected objects selectedList = Selector.MultipleObjects(2) if (selectedList == None): @@ -140,8 +164,3 @@ def BlendshapesExtraction(*args): cmds.select(selectedList, replace = True) -def RunBlendshapesLogic(*args): # TODO combine wraps and blendshapes logic - # result = WrapsCreateOnSelected() - # BlendshapesExtraction() - pass - diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 0cd4dc3..26eb8f2 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -45,6 +45,8 @@ class Presets: # TODO simplify "import GETOOLS_SOURCE.utils.Other as other" pathDeformers =\ "import GETOOLS_SOURCE.utils.Deformers as deformers" + pathBlendshapes =\ + "import GETOOLS_SOURCE.utils.Blendshapes as blendshapes" pathConstraints =\ "import GETOOLS_SOURCE.utils.Constraints as constraints" pathLocators =\ @@ -257,11 +259,21 @@ class Presets: # TODO simplify deformers.WrapsCreateOnSelected()\ '''.format(pathDeformers) - runBlendshapesProjecting ='''\ +# runWrapsConvert ='''\ # TODO +# {0} +# deformers.WrapsConvertFromSelected()\ +# '''.format(pathDeformers) + + runBlendshapesReconstruct ='''\ {0} -deformers.BlendshapesProjecting()\ +deformers.BlendshapesReconstruction()\ '''.format(pathDeformers) + runBlendshapesZeroWeights ='''\ +{0} +blendshapes.ZeroBlendshapeWeightsOnSelected()\ +'''.format(pathBlendshapes) + # EXPERIMENTAL runMotionTrailCreate ='''\ @@ -466,8 +478,12 @@ def ToShelf_CopySkin(path, *args): def ToShelf_WrapsCreate(path, *args): MoveToShelf(path, Presets.runWrapsCreate, "WrapsCreate", "WrapsCreate") -def ToShelf_BlendshapesProjecting(path, *args): - MoveToShelf(path, Presets.runBlendshapesProjecting, "BSProjecting", "BSProjecting") +# def ToShelf_WrapsConvert(path, *args): # TODO +# MoveToShelf(path, Presets.runWrapsConvert, "WrapsConvert", "WrapsConvert") +def ToShelf_BlendshapesReconstruct(path, *args): + MoveToShelf(path, Presets.runBlendshapesReconstruct, "BSReconstruct", "BSReconstruct") +def ToShelf_BlendshapesZeroWeights(path, *args): + MoveToShelf(path, Presets.runBlendshapesZeroWeights, "BSZeroWeights", "BSZeroWeights") # MOTION TRAIL From db6e4194b93b524e11eeed354ff663012262ebfd Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 13:20:39 -0700 Subject: [PATCH 13/27] add prototypes --- .../ToggleChannelBoxAndAttributeEditor.py | 8 +++++ GETOOLS_SOURCE/utils/Toggles.py | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 GETOOLS_SOURCE/_prototypes/ToggleChannelBoxAndAttributeEditor.py create mode 100644 GETOOLS_SOURCE/utils/Toggles.py diff --git a/GETOOLS_SOURCE/_prototypes/ToggleChannelBoxAndAttributeEditor.py b/GETOOLS_SOURCE/_prototypes/ToggleChannelBoxAndAttributeEditor.py new file mode 100644 index 0000000..acfc108 --- /dev/null +++ b/GETOOLS_SOURCE/_prototypes/ToggleChannelBoxAndAttributeEditor.py @@ -0,0 +1,8 @@ +if(`isChannelBoxRaised`) +{ + openAEWindow; +} +else if(`isAttributeEditorRaised`) +{ + raiseChannelBox; +} \ No newline at end of file diff --git a/GETOOLS_SOURCE/utils/Toggles.py b/GETOOLS_SOURCE/utils/Toggles.py new file mode 100644 index 0000000..0fd2881 --- /dev/null +++ b/GETOOLS_SOURCE/utils/Toggles.py @@ -0,0 +1,36 @@ +# GETOOLS is under the terms of the MIT License + +# Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene + +import maya.cmds as cmds + +# from ..utils import Selector + + +def ToggleJoints(*args): # TODO make universal tool for other types + currentPanel = cmds.getPanel(withFocus = True) + checkJoints = cmds.modelEditor(currentPanel, query = True, joints = True) + cmds.modelEditor(currentPanel, edit = True, joints = not checkJoints) + + print("Panel \"{0}\", Joints {1}".format(currentPanel, not checkJoints)) + From cfc2652efdbb8bccfaa4a9ff8356da2a2a36981a Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 13:26:08 -0700 Subject: [PATCH 14/27] save --- GETOOLS_SOURCE/utils/Deformers.py | 2 +- GETOOLS_SOURCE/utils/Scene.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index 6bed7c4..748f1d5 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -105,7 +105,7 @@ def WrapConvertToBlendshapes(blendshape): # TODO create single conversion logic def WrapsConvertFromSelected(*args): # TODO pass -def WrapsDelete(wraps): +def WrapsDelete(wraps): # TODO move out from current script, looks like just a regular delete method for wrap in wraps: cmds.delete(wrap) diff --git a/GETOOLS_SOURCE/utils/Scene.py b/GETOOLS_SOURCE/utils/Scene.py index 16d4c08..4f9b76f 100644 --- a/GETOOLS_SOURCE/utils/Scene.py +++ b/GETOOLS_SOURCE/utils/Scene.py @@ -29,7 +29,7 @@ def Reload(*args): if(currentScene): cmds.file(currentScene, open = True, force = True) else: - cmds.file(newFile = 1, force = 1) + cmds.file(newFile = True, force = True) def ExitMaya(*args): cmds.quit(force = True) From e189bc7ad201438770f05803e1dc48b517946075 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 14:57:52 -0700 Subject: [PATCH 15/27] add joint toggle button --- GETOOLS_SOURCE/modules/GeneralWindow.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index bc79188..7e00fc3 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -39,6 +39,7 @@ from ..utils import MotionTrail from ..utils import Scene from ..utils import Selector +from ..utils import Toggles from ..values import Icons @@ -96,6 +97,9 @@ def LayoutMenuBar(self, parentLayout): cmds.menuItem(label = "Dock Left", command = partial(self.DockToSide, Settings.dockAllowedAreas[0]), image = Icons.arrowLeft) cmds.menuItem(label = "Dock Right", command = partial(self.DockToSide, Settings.dockAllowedAreas[1]), image = Icons.arrowRight) cmds.menuItem(label = "Undock", command = self.DockOff, image = Icons.arrowDown) + + cmds.menu(label = "Toggles", tearOff = True) + cmds.menuItem(label = "Joints", command = Toggles.ToggleJoints) def ColorsPalette(*args): colorCalibration = Colors.ColorsPalette() @@ -113,7 +117,7 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(dividerLabel = "Blendshapes", divider = True) cmds.menuItem(label = "Print Blendshapes Base Nodes", command = Blendshapes.GetBlendshapeNodesFromSelected, image = Icons.text) cmds.menuItem(label = "Print Blendshapes Names", command = Blendshapes.GetBlendshapeWeightsFromSelected, image = Icons.text) - + self.LayoutMenuInstall() cmds.menu(label = "Help", tearOff = True) # , helpMenu = True From dfd581440f7021a06a172efd7c4043f465b3808c Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 15:09:04 -0700 Subject: [PATCH 16/27] save: - add tear off to sub menus - fix motion trails to shelf button --- GETOOLS_SOURCE/modules/GeneralWindow.py | 46 ++++++++++++------------- GETOOLS_SOURCE/utils/Install.py | 8 +++-- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 7e00fc3..9a2111b 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -97,9 +97,6 @@ def LayoutMenuBar(self, parentLayout): cmds.menuItem(label = "Dock Left", command = partial(self.DockToSide, Settings.dockAllowedAreas[0]), image = Icons.arrowLeft) cmds.menuItem(label = "Dock Right", command = partial(self.DockToSide, Settings.dockAllowedAreas[1]), image = Icons.arrowRight) cmds.menuItem(label = "Undock", command = self.DockOff, image = Icons.arrowDown) - - cmds.menu(label = "Toggles", tearOff = True) - cmds.menuItem(label = "Joints", command = Toggles.ToggleJoints) def ColorsPalette(*args): colorCalibration = Colors.ColorsPalette() @@ -117,6 +114,9 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(dividerLabel = "Blendshapes", divider = True) cmds.menuItem(label = "Print Blendshapes Base Nodes", command = Blendshapes.GetBlendshapeNodesFromSelected, image = Icons.text) cmds.menuItem(label = "Print Blendshapes Names", command = Blendshapes.GetBlendshapeWeightsFromSelected, image = Icons.text) + + cmds.menu(label = "Toggle", tearOff = True) + cmds.menuItem(label = "Joints", command = Toggles.ToggleJoints, image = Icons.joint) self.LayoutMenuInstall() @@ -179,7 +179,7 @@ def LayerMove(*args): def LayoutMenuInstall(self): cmds.menu(label = "To Shelf", tearOff = True) ### - cmds.menuItem(subMenu = True, label = "General", image = Icons.fileOpen) + cmds.menuItem(subMenu = True, label = "General", tearOff = True, image = Icons.fileOpen) cmds.menuItem(dividerLabel = "File", divider = True) cmds.menuItem(label = "Reload Scene (force)", command = partial(Install.ToShelf_ReloadScene, self.directory)) cmds.menuItem(label = "Exit Maya (force)", command = partial(Install.ToShelf_ExitMaya, self.directory)) @@ -190,7 +190,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "TOOLS - Locators", divider = True) ### - cmds.menuItem(subMenu = True, label = "Size") + cmds.menuItem(subMenu = True, label = "Size", tearOff = True) cmds.menuItem(label = "50%", command = partial(Install.ToShelf_LocatorsSizeScale50, self.directory)) cmds.menuItem(label = "90%", command = partial(Install.ToShelf_LocatorsSizeScale90, self.directory)) cmds.menuItem(divider = True) @@ -198,26 +198,26 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "200%", command = partial(Install.ToShelf_LocatorsSizeScale200, self.directory)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Create", image = Icons.locator) + cmds.menuItem(subMenu = True, label = "Create", tearOff = True, image = Icons.locator) cmds.menuItem(label = "Locator", command = partial(Install.ToShelf_LocatorCreate, self.directory)) cmds.menuItem(label = "Match", command = partial(Install.ToShelf_LocatorsMatch, self.directory)) cmds.menuItem(label = "Parent", command = partial(Install.ToShelf_LocatorsParent, self.directory)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Pin", image = Icons.pin) + cmds.menuItem(subMenu = True, label = "Pin", tearOff = True, image = Icons.pin) cmds.menuItem(label = "Pin", command = partial(Install.ToShelf_LocatorsPin, self.directory)) cmds.menuItem(label = "Without reverse constraint", command = partial(Install.ToShelf_LocatorsPinWithoutReverse, self.directory)) cmds.menuItem(label = "POS", command = partial(Install.ToShelf_LocatorsPinPos, self.directory)) cmds.menuItem(label = "ROT", command = partial(Install.ToShelf_LocatorsPinRot, self.directory)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Relative", image = Icons.pinInvert) + cmds.menuItem(subMenu = True, label = "Relative", tearOff = True, image = Icons.pinInvert) cmds.menuItem(label = "Relative", command = partial(Install.ToShelf_LocatorsRelative, self.directory)) cmds.menuItem(label = "Skip last object reverse constraint", command = partial(Install.ToShelf_LocatorsRelativeSkipLast, self.directory)) cmds.menuItem(label = "Without reverse constraint", command = partial(Install.ToShelf_LocatorsRelativeWithoutReverse, self.directory)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Aim", image = Icons.pin) + cmds.menuItem(subMenu = True, label = "Aim", tearOff = True, image = Icons.pin) minus = "-" plus = "+" axisX = "X" @@ -251,7 +251,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "TOOLS - Baking", divider = True) ### - cmds.menuItem(subMenu = True, label = "Bake") + cmds.menuItem(subMenu = True, label = "Bake", tearOff = True) cmds.menuItem(label = "Classic", command = partial(Install.ToShelf_BakeClassic, self.directory)) cmds.menuItem(label = "Classic Cut Out", command = partial(Install.ToShelf_BakeClassicCutOut, self.directory)) cmds.menuItem(divider = True) @@ -259,13 +259,13 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Custom Cut Out", command = partial(Install.ToShelf_BakeCustomCutOut, self.directory)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "By Last") + cmds.menuItem(subMenu = True, label = "By Last", tearOff = True) cmds.menuItem(label = "By Last", command = partial(Install.ToShelf_BakeByLast, self.directory, True, True)) cmds.menuItem(label = "POS", command = partial(Install.ToShelf_BakeByLast, self.directory, True, False)) cmds.menuItem(label = "ROT", command = partial(Install.ToShelf_BakeByLast, self.directory, False, True)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "World", image = Icons.world) + cmds.menuItem(subMenu = True, label = "World", tearOff = True, image = Icons.world) cmds.menuItem(label = "World", command = partial(Install.ToShelf_BakeByWorld, self.directory, True, True)) cmds.menuItem(label = "POS", command = partial(Install.ToShelf_BakeByWorld, self.directory, True, False)) cmds.menuItem(label = "ROT", command = partial(Install.ToShelf_BakeByWorld, self.directory, False, True)) @@ -273,7 +273,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "TOOLS - Animation", divider = True) ### - cmds.menuItem(subMenu = True, label = "Delete", image = Icons.delete) + cmds.menuItem(subMenu = True, label = "Delete", tearOff = True, image = Icons.delete) cmds.menuItem(label = "Animation", command = partial(Install.ToShelf_DeleteKeys, self.directory)) cmds.menuItem(label = "Nonkeyable", command = partial(Install.ToShelf_DeleteNonkeyable, self.directory)) cmds.menuItem(label = "Static", command = partial(Install.ToShelf_DeleteStatic, self.directory)) @@ -281,7 +281,7 @@ def LayoutMenuInstall(self): # cmds.menuItem(label = "Euler Filter", command = partial(Install.ToShelf_EulerFilter, self.directory), image = Icons.filter) # - cmds.menuItem(subMenu = True, label = "Infinity") + cmds.menuItem(subMenu = True, label = "Infinity", tearOff = True) cmds.menuItem(label = "Constant", command = partial(Install.ToShelf_SetInfinity, self.directory, 1)) cmds.menuItem(label = "Linear", command = partial(Install.ToShelf_SetInfinity, self.directory, 2)) cmds.menuItem(divider = True) @@ -291,7 +291,7 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Oscillate", command = partial(Install.ToShelf_SetInfinity, self.directory, 5)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Offset") + cmds.menuItem(subMenu = True, label = "Offset", tearOff = True) cmds.menuItem(label = "-3", command = partial(Install.ToShelf_AnimOffset, self.directory, -1, 3)) cmds.menuItem(label = "-2", command = partial(Install.ToShelf_AnimOffset, self.directory, -1, 2)) cmds.menuItem(label = "-1", command = partial(Install.ToShelf_AnimOffset, self.directory, -1, 1)) @@ -303,7 +303,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "TOOLS - Timeline", divider = True) ### - cmds.menuItem(subMenu = True, label = "Timeline") + cmds.menuItem(subMenu = True, label = "Timeline", tearOff = True) cmds.menuItem(label = "Min Out", command = partial(Install.ToShelf_SetTimelineMinOut, self.directory)) cmds.menuItem(label = "Min In", command = partial(Install.ToShelf_SetTimelineMinIn, self.directory)) cmds.menuItem(divider = True) @@ -318,7 +318,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "RIGGING - Constraints", divider = True) ### - cmds.menuItem(subMenu = True, label = "Constraints", image = Icons.constraint) + cmds.menuItem(subMenu = True, label = "Constraints", tearOff = True, image = Icons.constraint) cmds.menuItem(label = "Parent", command = partial(Install.ToShelf_Constraint, self.directory, False, True, False, False, False)) cmds.menuItem(label = "Point", command = partial(Install.ToShelf_Constraint, self.directory, False, False, True, False, False)) cmds.menuItem(label = "Orient", command = partial(Install.ToShelf_Constraint, self.directory, False, False, False, True, False)) @@ -330,24 +330,24 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Scale with maintain", command = partial(Install.ToShelf_Constraint, self.directory, True, False, False, False, True)) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Connections", image = Icons.constraint) + cmds.menuItem(subMenu = True, label = "Connections", tearOff = True, image = Icons.constraint) cmds.menuItem(label = "Disconnect", command = partial(Install.ToShelf_DisconnectTargets, self.directory)) cmds.menuItem(label = "Delete Constraints", command = partial(Install.ToShelf_DeleteConstraints, self.directory)) cmds.setParent('..', menu = True) cmds.menuItem(dividerLabel = "RIGGING - Utils", divider = True) ### - cmds.menuItem(subMenu = True, label = "Rotate Order") + cmds.menuItem(subMenu = True, label = "Rotate Order", tearOff = True) cmds.menuItem(label = "Show", command = partial(Install.ToShelf_RotateOrder, self.directory, True), image = Icons.visibleOn) cmds.menuItem(label = "Hide", command = partial(Install.ToShelf_RotateOrder, self.directory, False), image = Icons.visibleOff) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Segment Scale Compensate", image = Icons.joint) + cmds.menuItem(subMenu = True, label = "Segment Scale Compensate", tearOff = True, image = Icons.joint) cmds.menuItem(label = "On", command = partial(Install.ToShelf_SegmentScaleCompensate, self.directory, True), image = Icons.on) cmds.menuItem(label = "Off", command = partial(Install.ToShelf_SegmentScaleCompensate, self.directory, False), image = Icons.off) cmds.setParent('..', menu = True) # - cmds.menuItem(subMenu = True, label = "Joint Draw Style", image = Icons.joint) + cmds.menuItem(subMenu = True, label = "Joint Draw Style", tearOff = True, image = Icons.joint) cmds.menuItem(label = "Bone", command = partial(Install.ToShelf_JointDrawStyle, self.directory, 0), image = Icons.visibleOn) cmds.menuItem(label = "Hidden", command = partial(Install.ToShelf_JointDrawStyle, self.directory, 2), image = Icons.visibleOff) cmds.setParent('..', menu = True) @@ -356,7 +356,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "RIGGING - Blendshapes", divider = True) ### - # cmds.menuItem(subMenu = True, label = "Rotate Order") + # cmds.menuItem(subMenu = True, label = "Rotate Order", tearOff = True) cmds.menuItem(label = "Wraps Create", command = partial(Install.ToShelf_WrapsCreate, self.directory), image = Icons.wrap) # cmds.menuItem(label = "Wraps Convert", command = partial(Install.ToShelf_WrapsCreate, self.directory), image = Icons.wrap) # TODO cmds.menuItem(label = "Reconstruct", command = partial(Install.ToShelf_BlendshapesReconstruct, self.directory), image = Icons.blendshape) @@ -365,7 +365,7 @@ def LayoutMenuInstall(self): cmds.menuItem(dividerLabel = "EXPERIMENTAL", divider = True) ### - cmds.menuItem(subMenu = True, label = "Motion Trail") + cmds.menuItem(subMenu = True, label = "Motion Trail", tearOff = True) cmds.menuItem(label = "Create", command = partial(Install.ToShelf_MotionTrailCreate, self.directory)) cmds.menuItem(label = "Select", command = partial(Install.ToShelf_MotionTrailSelect, self.directory)) cmds.menuItem(label = "Delete", command = partial(Install.ToShelf_MotionTrailDelete, self.directory)) diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 26eb8f2..a760d0c 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -279,15 +279,17 @@ class Presets: # TODO simplify runMotionTrailCreate ='''\ {0} mtrail.Create()\ -'''.format(pathLocators) +'''.format(pathMotionTrail) + runMotionTrailSelect ='''\ {0} mtrail.Select()\ -'''.format(pathLocators) +'''.format(pathMotionTrail) + runMotionTrailDelete ='''\ {0} mtrail.Delete()\ -'''.format(pathLocators) +'''.format(pathMotionTrail) # LOGIC From a6b991f56f56ab3555bc22dbfdee404e180d3b04 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 28 Jun 2024 15:17:49 -0700 Subject: [PATCH 17/27] add toggle joint to shelf logic --- GETOOLS_SOURCE/modules/GeneralWindow.py | 8 ++++++++ GETOOLS_SOURCE/utils/Install.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 9a2111b..cc24ee0 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -188,6 +188,14 @@ def LayoutMenuInstall(self): # cmds.menuItem(label = "Create Reset Button", command = partial(Install.ToShelf_CreateResetButton, self.directory), image = Icons.reset) cmds.setParent('..', menu = True) + cmds.menuItem(dividerLabel = "TOGGLE", divider = True) + ### + cmds.menuItem(subMenu = True, label = "Size", tearOff = True) + cmds.menuItem(label = "Joints", command = partial(Install.ToShelf_ToggleJoints, self.directory), image = Icons.joint) + # cmds.menuItem(label = "Meshes", command = partial(Install.ToShelf_ToggleJoints, self.directory)) + # cmds.menuItem(label = "Nurbs", command = partial(Install.ToShelf_ToggleJoints, self.directory)) + cmds.setParent('..', menu = True) + cmds.menuItem(dividerLabel = "TOOLS - Locators", divider = True) ### cmds.menuItem(subMenu = True, label = "Size", tearOff = True) diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index a760d0c..6342b72 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -37,6 +37,8 @@ class Presets: # TODO simplify "import GETOOLS_SOURCE.utils.Scene as scene" pathInstall =\ "import GETOOLS_SOURCE.utils.Install as install" + pathToggles =\ + "import GETOOLS_SOURCE.utils.Toggles as toggles" pathBaker =\ "import GETOOLS_SOURCE.utils.Baker as baker" pathSelector =\ @@ -92,6 +94,13 @@ class Presets: # TODO simplify '''.format(pathInstall) + # TOGGLES + runToggleJoints ='''\ +{0} +toggles.ToggleJoints()\ +'''.format(pathToggles) + + # LOCATORS runLocatorsSizeScale ='''\ {0} @@ -337,6 +346,10 @@ def ToShelf_SelectHierarchy(path, *args): def ToShelf_CreateResetButton(path, *args): MoveToShelf(path, Presets.runCreateResetButton, "CreateResetButton", "Reset") +# TOGGLES +def ToShelf_ToggleJoints(path, *args): + MoveToShelf(path, Presets.runToggleJoints, "ToggleJoints", "tglJoints") + # LOCATORS def ToShelf_LocatorsSizeScale50(path, *args): MoveToShelf(path, Presets.runLocatorsSizeScale + "(0.5)", "LocatorsSizeScale50", "L50%") From 03049e558a46db619d16e73bfc864f249ecb8e71 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 5 Jul 2024 01:18:52 -0700 Subject: [PATCH 18/27] Create SetAttributesBySimpleName.py --- .../_prototypes/SetAttributesBySimpleName.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py diff --git a/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py b/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py new file mode 100644 index 0000000..6bd5e96 --- /dev/null +++ b/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py @@ -0,0 +1,25 @@ +import maya.cmds as cmds + +def FindAllObjects(objName): + objects = cmds.ls(type = "transform", long = True) + result = [] + for item in objects: + if(item.endswith(objName)): + result.append(item) + return result + +def SetAttributes(objectList): + for item in objectList: + cmds.setAttr(item + ".translateX", 0) + cmds.setAttr(item + ".translateY", 0) + cmds.setAttr(item + ".translateZ", 0) + +def SetAttributesUnique(objectList): + for item in objectList: + cmds.setAttr(item + ".translateY", 0.5) + +objNameL = "testL" +objNameR = "testR" +SetAttributes(FindAllObjects(objNameL)) +SetAttributes(FindAllObjects(objNameR)) +SetAttributesUnique(FindAllObjects(objNameR)) \ No newline at end of file From 22e5ac97938fbdf5ce79ddb423b05744d20aca5c Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 5 Jul 2024 09:49:52 -0700 Subject: [PATCH 19/27] limit name search --- GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py b/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py index 6bd5e96..2c8018f 100644 --- a/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py +++ b/GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py @@ -4,7 +4,7 @@ def FindAllObjects(objName): objects = cmds.ls(type = "transform", long = True) result = [] for item in objects: - if(item.endswith(objName)): + if(item.endswith("|" + objName) or item.endswith(":" + objName)): result.append(item) return result From 26e389096562d5e47fd6a32494932a8d7f9d6d8b Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 8 Jul 2024 11:10:34 -0700 Subject: [PATCH 20/27] Update Install.py --- GETOOLS_SOURCE/utils/Install.py | 312 +++++++------------------------- 1 file changed, 61 insertions(+), 251 deletions(-) diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 6342b72..452f6d0 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -30,275 +30,85 @@ from ..values import Enums -class Presets: # TODO simplify - pathGeneral =\ - "import GETOOLS_SOURCE.modules.GeneralWindow as gtwindow" - pathScene =\ - "import GETOOLS_SOURCE.utils.Scene as scene" - pathInstall =\ - "import GETOOLS_SOURCE.utils.Install as install" - pathToggles =\ - "import GETOOLS_SOURCE.utils.Toggles as toggles" - pathBaker =\ - "import GETOOLS_SOURCE.utils.Baker as baker" - pathSelector =\ - "import GETOOLS_SOURCE.utils.Selector as selector" - pathOther =\ - "import GETOOLS_SOURCE.utils.Other as other" - pathDeformers =\ - "import GETOOLS_SOURCE.utils.Deformers as deformers" - pathBlendshapes =\ - "import GETOOLS_SOURCE.utils.Blendshapes as blendshapes" - pathConstraints =\ - "import GETOOLS_SOURCE.utils.Constraints as constraints" - pathLocators =\ - "import GETOOLS_SOURCE.utils.Locators as locators" - pathTimeline =\ - "import GETOOLS_SOURCE.utils.Timeline as timeline" - pathAnimation =\ - "import GETOOLS_SOURCE.utils.Animation as animation" - pathSkinning =\ - "import GETOOLS_SOURCE.utils.Skinning as skinning" - pathMotionTrail =\ - "import GETOOLS_SOURCE.utils.MotionTrail as mtrail" - +class Presets: + pathGeneral = "import GETOOLS_SOURCE.modules.GeneralWindow as gtwindow" + pathAnimation = "import GETOOLS_SOURCE.utils.Animation as animation" + pathBaker = "import GETOOLS_SOURCE.utils.Baker as baker" + pathBlendshapes = "import GETOOLS_SOURCE.utils.Blendshapes as blendshapes" + pathConstraints = "import GETOOLS_SOURCE.utils.Constraints as constraints" + pathDeformers = "import GETOOLS_SOURCE.utils.Deformers as deformers" + pathInstall = "import GETOOLS_SOURCE.utils.Install as install" + pathLocators = "import GETOOLS_SOURCE.utils.Locators as locators" + pathMotionTrail = "import GETOOLS_SOURCE.utils.MotionTrail as mtrail" + pathOther = "import GETOOLS_SOURCE.utils.Other as other" + pathScene = "import GETOOLS_SOURCE.utils.Scene as scene" + pathSelector = "import GETOOLS_SOURCE.utils.Selector as selector" + pathSkinning = "import GETOOLS_SOURCE.utils.Skinning as skinning" + pathTimeline = "import GETOOLS_SOURCE.utils.Timeline as timeline" + pathToggles = "import GETOOLS_SOURCE.utils.Toggles as toggles" # GENERAL - runGeneralWindow ='''\ -{0} -gtwindow.GeneralWindow().RUN_DOCKED()\ -'''.format(pathGeneral) - + runGeneralWindow = pathGeneral + "\n" + "gtwindow.GeneralWindow().RUN_DOCKED()" # FILE - runSceneReload ='''\ -{0} -scene.Reload()\ -'''.format(pathScene) - - runExitMaya ='''\ -{0} -scene.ExitMaya()\ -'''.format(pathScene) - + runSceneReload = pathScene + "\n" + "scene.Reload()" + runExitMaya = pathScene + "\n" + "scene.ExitMaya()" # UTILS - runSelectHierarchy ='''\ -{0} -selector.SelectHierarchy()\ -'''.format(pathSelector) - - runCreateResetButton ='''\ -{0} -install.CreateResetButton()\ -'''.format(pathInstall) - + runSelectHierarchy = pathSelector + "\n" + "selector.SelectHierarchy()" + runCreateResetButton = pathInstall + "\n" + "install.CreateResetButton()" # TOGGLES - runToggleJoints ='''\ -{0} -toggles.ToggleJoints()\ -'''.format(pathToggles) - + runToggleJoints = pathToggles + "\n" + "toggles.ToggleJoints()" # LOCATORS - runLocatorsSizeScale ='''\ -{0} -locators.SelectedLocatorsSizeScale\ -'''.format(pathLocators) - - runLocatorsSizeSet ='''\ -{0} -locators.SelectedLocatorsSizeSet\ -'''.format(pathLocators) - - runLocatorCreate ='''\ -{0} -locators.Create()\ -'''.format(pathLocators) - - runLocatorsMatch ='''\ -{0} -locators.CreateOnSelected(constraint = False)\ -'''.format(pathLocators) - - runLocatorsParent ='''\ -{0} -locators.CreateOnSelected(constraint = True)\ -'''.format(pathLocators) - - runLocatorsPin ='''\ -{0} -locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = True)\ -'''.format(pathLocators) - - runLocatorsPinWithoutReverse ='''\ -{0} -locators.CreateOnSelected(constraint = True, bake = True)\ -'''.format(pathLocators) - - runLocatorsPinPos ='''\ -{0} -locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = False)\ -'''.format(pathLocators) - - runLocatorsPinRot ='''\ -{0} -locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = False, constrainRotate = True)\ -'''.format(pathLocators) - - runLocatorsRelative ='''\ -{0} -locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True, skipLastReverse = False)\ -'''.format(pathLocators) - - runLocatorsRelativeSkipLast ='''\ -{0} -locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True)\ -'''.format(pathLocators) - - runLocatorsRelativeWithoutReverse ='''\ -{0} -locators.CreateAndBakeAsChildrenFromLastSelected()\ -'''.format(pathLocators) - - runLocatorsAim ='''\ -{0} -locators.CreateOnSelectedAim\ -'''.format(pathLocators) - + runLocatorsSizeScale = pathLocators + "\n" + "locators.SelectedLocatorsSizeScale" + runLocatorsSizeSet = pathLocators + "\n" + "locators.SelectedLocatorsSizeSet" + runLocatorCreate = pathLocators + "\n" + "locators.Create()" + runLocatorsMatch = pathLocators + "\n" + "locators.CreateOnSelected(constraint = False)" + runLocatorsParent = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True)" + runLocatorsPin = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = True)" + runLocatorsPinWithoutReverse = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True)" + runLocatorsPinPos = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = False)" + runLocatorsPinRot = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = False, constrainRotate = True)" + runLocatorsRelative = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True, skipLastReverse = False)" + runLocatorsRelativeSkipLast = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True)" + runLocatorsRelativeWithoutReverse = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected()" + runLocatorsAim = pathLocators + "\n" + "locators.CreateOnSelectedAim" # BAKING - runBakeClassic ='''\ -{0} -baker.BakeSelected\ -'''.format(pathBaker) - - runBakeCustom ='''\ -{0} -baker.BakeSelected\ -'''.format(pathBaker) - - runBakeByLast ='''\ -{0} -baker.BakeSelectedByLastObject\ -'''.format(pathBaker) - - runBakeByWorld ='''\ -{0} -baker.BakeSelectedByWorld\ -'''.format(pathBaker) - + runBakeClassic = pathBaker + "\n" + "baker.BakeSelected" + runBakeCustom = pathBaker + "\n" + "baker.BakeSelected" + runBakeByLast = pathBaker + "\n" + "baker.BakeSelectedByLastObject" + runBakeByWorld = pathBaker + "\n" + "baker.BakeSelectedByWorld" # ANIMATION - runAnimOffset ='''\ -{0} -animation.OffsetObjects\ -'''.format(pathAnimation) - - runDeleteKeys ='''\ -{0} -animation.DeleteKeys(True)\ -'''.format(pathAnimation) - - runDeleteNonkeyable ='''\ -{0} -animation.DeleteKeysNonkeyable()\ -'''.format(pathAnimation) - - runDeleteStatic ='''\ -{0} -animation.DeleteStaticCurves()\ -'''.format(pathAnimation) - - runEulerFilter ='''\ -{0} -animation.FilterCurve()\ -'''.format(pathAnimation) - - runSetInfinity ='''\ -{0} -animation.SetInfinity\ -'''.format(pathAnimation) - - runSetTimeline ='''\ -{0} -timeline.SetTime\ -'''.format(pathTimeline) - + runAnimOffset = pathAnimation + "\n" + "animation.OffsetObjects" + runDeleteKeys = pathAnimation + "\n" + "animation.DeleteKeys(True)" + runDeleteNonkeyable = pathAnimation + "\n" + "animation.DeleteKeysNonkeyable()" + runDeleteStatic = pathAnimation + "\n" + "animation.DeleteStaticCurves()" + runEulerFilter = pathAnimation + "\n" + "animation.FilterCurve()" + runSetInfinity = pathAnimation + "\n" + "animation.SetInfinity" + runSetTimeline = pathTimeline + "\n" + "timeline.SetTime" # RIGGING - runConstraint ='''\ -{0} -constraints.ConstrainSelectedToLastObject\ -'''.format(pathConstraints) - - runDeleteConstraints ='''\ -{0} -constraints.DeleteConstraintsOnSelected()\ -'''.format(pathConstraints) - - runDisconnectTargets ='''\ -{0} -constraints.DisconnectTargetsFromConstraintOnSelected()\ -'''.format(pathConstraints) - - runRotateOrder ='''\ -{0} -other.RotateOrderVisibility\ -'''.format(pathOther) - - runSegmentScaleCompensateCompensate ='''\ -{0} -other.SegmentScaleCompensate\ -'''.format(pathOther) - - runJointDrawStyle ='''\ -{0} -other.JointDrawStyle\ -'''.format(pathOther) - - runCopySkin ='''\ -{0} -skinning.CopySkinWeightsFromLastMesh()\ -'''.format(pathSkinning) - - runWrapsCreate ='''\ -{0} -deformers.WrapsCreateOnSelected()\ -'''.format(pathDeformers) - -# runWrapsConvert ='''\ # TODO -# {0} -# deformers.WrapsConvertFromSelected()\ -# '''.format(pathDeformers) - - runBlendshapesReconstruct ='''\ -{0} -deformers.BlendshapesReconstruction()\ -'''.format(pathDeformers) - - runBlendshapesZeroWeights ='''\ -{0} -blendshapes.ZeroBlendshapeWeightsOnSelected()\ -'''.format(pathBlendshapes) - + runConstraint = pathConstraints + "\n" + "constraints.ConstrainSelectedToLastObject" + runDeleteConstraints = pathConstraints + "\n" + "constraints.DeleteConstraintsOnSelected()" + runDisconnectTargets = pathConstraints + "\n" + "constraints.DisconnectTargetsFromConstraintOnSelected()" + runRotateOrder = pathOther + "\n" + "other.RotateOrderVisibility" + runSegmentScaleCompensateCompensate = pathOther + "\n" + "other.SegmentScaleCompensate" + runJointDrawStyle = pathOther + "\n" + "other.JointDrawStyle" + runCopySkin = pathSkinning + "\n" + "skinning.CopySkinWeightsFromLastMesh()" + runWrapsCreate = pathDeformers + "\n" + "deformers.WrapsCreateOnSelected()" + + # runWrapsConvert = pathDeformers + "\n" + "ndeformers.WrapsConvertFromSelected()" # TODO + runBlendshapesReconstruct = pathDeformers + "\n" + "deformers.BlendshapesReconstruction()" + runBlendshapesZeroWeights = pathBlendshapes + "\n" + "blendshapes.ZeroBlendshapeWeightsOnSelected()" # EXPERIMENTAL - runMotionTrailCreate ='''\ -{0} -mtrail.Create()\ -'''.format(pathMotionTrail) - - runMotionTrailSelect ='''\ -{0} -mtrail.Select()\ -'''.format(pathMotionTrail) - - runMotionTrailDelete ='''\ -{0} -mtrail.Delete()\ -'''.format(pathMotionTrail) + runMotionTrailCreate = pathMotionTrail + "\n" + "mtrail.Create()" + runMotionTrailSelect = pathMotionTrail + "\n" + "mtrail.Select()" + runMotionTrailDelete = pathMotionTrail + "\n" + "mtrail.Delete()" # LOGIC From 735f99762592d346a60d7f48da73726773db0599 Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 8 Jul 2024 12:43:26 -0700 Subject: [PATCH 21/27] add more toggles --- GETOOLS_SOURCE/modules/GeneralWindow.py | 74 ++++++++++++++++++++++--- GETOOLS_SOURCE/utils/Install.py | 67 +++++++++++++++++++++- GETOOLS_SOURCE/utils/Toggles.py | 47 ++++++++++++++-- GETOOLS_SOURCE/values/Enums.py | 33 +++++++++++ GETOOLS_SOURCE/values/Icons.py | 18 +++++- 5 files changed, 221 insertions(+), 18 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index cc24ee0..82064dd 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -116,7 +116,37 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(label = "Print Blendshapes Names", command = Blendshapes.GetBlendshapeWeightsFromSelected, image = Icons.text) cmds.menu(label = "Toggle", tearOff = True) + # cmds.menuItem(label = "All Objects", command = Toggles.ToggleAllObjects) + cmds.menuItem(label = "Cameras", command = Toggles.ToggleCameras, image = Icons.camera) + cmds.menuItem(label = "Control Vertices", command = Toggles.ToggleControlVertices) + cmds.menuItem(label = "Deformers", command = Toggles.ToggleDeformers) + cmds.menuItem(label = "Dimensions", command = Toggles.ToggleDimensions) + cmds.menuItem(label = "Dynamic Constraints", command = Toggles.ToggleDynamicConstraints, image = Icons.dynamicConstraint) + cmds.menuItem(label = "Dynamics", command = Toggles.ToggleDynamics) + cmds.menuItem(label = "Fluids", command = Toggles.ToggleFluids) + cmds.menuItem(label = "Follicles", command = Toggles.ToggleFollicles, image = Icons.follicle) + cmds.menuItem(label = "Grid", command = Toggles.ToggleGrid, image = Icons.grid) + cmds.menuItem(label = "Hair Systems", command = Toggles.ToggleHairSystems, image = Icons.hairSystem) + cmds.menuItem(label = "Handles", command = Toggles.ToggleHandles) + cmds.menuItem(label = "Hulls", command = Toggles.ToggleHulls) + cmds.menuItem(label = "IK Handles", command = Toggles.ToggleIkHandles, image = Icons.ikHandle) cmds.menuItem(label = "Joints", command = Toggles.ToggleJoints, image = Icons.joint) + cmds.menuItem(label = "Lights", command = Toggles.ToggleLights, image = Icons.light) + cmds.menuItem(label = "Locators", command = Toggles.ToggleLocators, image = Icons.locator) + cmds.menuItem(label = "Manipulators", command = Toggles.ToggleManipulators) + cmds.menuItem(label = "NCloths", command = Toggles.ToggleNCloths, image = Icons.nCloth) + cmds.menuItem(label = "NParticles", command = Toggles.ToggleNParticles, image = Icons.particle) + cmds.menuItem(label = "NRigids", command = Toggles.ToggleNRigids, image = Icons.nRigid) + cmds.menuItem(label = "Nurbs Curves", command = Toggles.ToggleNurbsCurves, image = Icons.nurbsCurve) + cmds.menuItem(label = "Nurbs Surfaces", command = Toggles.ToggleNurbsSurfaces, image = Icons.nurbsSurface) + cmds.menuItem(label = "Pivots", command = Toggles.TogglePivots) + cmds.menuItem(label = "Planes", command = Toggles.TogglePlanes, image = Icons.plane) + cmds.menuItem(label = "Poly Meshes", command = Toggles.TogglePolymeshes, image = Icons.polyMesh) + cmds.menuItem(label = "Shadows", command = Toggles.ToggleShadows, image = Icons.shadows) + cmds.menuItem(label = "Strokes", command = Toggles.ToggleStrokes, image = Icons.stroke) + cmds.menuItem(label = "Subdiv Surfaces", command = Toggles.ToggleSubdivSurfaces) + cmds.menuItem(label = "Textures", command = Toggles.ToggleTextures) + self.LayoutMenuInstall() @@ -178,22 +208,48 @@ def LayerMove(*args): pass def LayoutMenuInstall(self): cmds.menu(label = "To Shelf", tearOff = True) - ### - cmds.menuItem(subMenu = True, label = "General", tearOff = True, image = Icons.fileOpen) - cmds.menuItem(dividerLabel = "File", divider = True) + + cmds.menuItem(subMenu = True, label = "File", tearOff = True, image = Icons.fileOpen) cmds.menuItem(label = "Reload Scene (force)", command = partial(Install.ToShelf_ReloadScene, self.directory)) cmds.menuItem(label = "Exit Maya (force)", command = partial(Install.ToShelf_ExitMaya, self.directory)) - cmds.menuItem(dividerLabel = "Utils", divider = True) + cmds.setParent('..', menu = True) + + cmds.menuItem(subMenu = True, label = "Utils", tearOff = True) cmds.menuItem(label = "Select Hiererchy", command = partial(Install.ToShelf_SelectHierarchy, self.directory)) # cmds.menuItem(label = "Create Reset Button", command = partial(Install.ToShelf_CreateResetButton, self.directory), image = Icons.reset) cmds.setParent('..', menu = True) - cmds.menuItem(dividerLabel = "TOGGLE", divider = True) - ### - cmds.menuItem(subMenu = True, label = "Size", tearOff = True) + cmds.menuItem(subMenu = True, label = "Toggle", tearOff = True) + # cmds.menuItem(label = "All Objects", command = partial(Install.ToShelf_ToggleAllObjects, self.directory)) + cmds.menuItem(label = "Cameras", command = partial(Install.ToShelf_ToggleCameras, self.directory), image = Icons.camera) + cmds.menuItem(label = "Control Vertices", command = partial(Install.ToShelf_ToggleControlVertices, self.directory)) + cmds.menuItem(label = "Deformers", command = partial(Install.ToShelf_ToggleDeformers, self.directory)) + cmds.menuItem(label = "Dimensions", command = partial(Install.ToShelf_ToggleDimensions, self.directory)) + cmds.menuItem(label = "Dynamic Constraints", command = partial(Install.ToShelf_ToggleDynamicConstraints, self.directory), image = Icons.dynamicConstraint) + cmds.menuItem(label = "Dynamics", command = partial(Install.ToShelf_ToggleDynamics, self.directory)) + cmds.menuItem(label = "Fluids", command = partial(Install.ToShelf_ToggleFluids, self.directory)) + cmds.menuItem(label = "Follicles", command = partial(Install.ToShelf_ToggleFollicles, self.directory), image = Icons.follicle) + cmds.menuItem(label = "Grid", command = partial(Install.ToShelf_ToggleGrid, self.directory), image = Icons.grid) + cmds.menuItem(label = "Hair Systems", command = partial(Install.ToShelf_ToggleHairSystems, self.directory), image = Icons.hairSystem) + cmds.menuItem(label = "Handles", command = partial(Install.ToShelf_ToggleHandles, self.directory)) + cmds.menuItem(label = "Hulls", command = partial(Install.ToShelf_ToggleHulls, self.directory)) + cmds.menuItem(label = "IK Handles", command = partial(Install.ToShelf_ToggleIkHandles, self.directory), image = Icons.ikHandle) cmds.menuItem(label = "Joints", command = partial(Install.ToShelf_ToggleJoints, self.directory), image = Icons.joint) - # cmds.menuItem(label = "Meshes", command = partial(Install.ToShelf_ToggleJoints, self.directory)) - # cmds.menuItem(label = "Nurbs", command = partial(Install.ToShelf_ToggleJoints, self.directory)) + cmds.menuItem(label = "Lights", command = partial(Install.ToShelf_ToggleLights, self.directory), image = Icons.light) + cmds.menuItem(label = "Locators", command = partial(Install.ToShelf_ToggleLocators, self.directory), image = Icons.locator) + cmds.menuItem(label = "Manipulators", command = partial(Install.ToShelf_ToggleManipulators, self.directory)) + cmds.menuItem(label = "NCloths", command = partial(Install.ToShelf_ToggleNCloths, self.directory), image = Icons.nCloth) + cmds.menuItem(label = "NParticles", command = partial(Install.ToShelf_ToggleNParticles, self.directory), image = Icons.particle) + cmds.menuItem(label = "NRigids", command = partial(Install.ToShelf_ToggleNRigids, self.directory), image = Icons.nRigid) + cmds.menuItem(label = "Nurbs Curves", command = partial(Install.ToShelf_ToggleNurbsCurves, self.directory), image = Icons.nurbsCurve) + cmds.menuItem(label = "Nurbs Surfaces", command = partial(Install.ToShelf_ToggleNurbsSurfaces, self.directory), image = Icons.nurbsSurface) + cmds.menuItem(label = "Pivots", command = partial(Install.ToShelf_TogglePivots, self.directory)) + cmds.menuItem(label = "Planes", command = partial(Install.ToShelf_TogglePlanes, self.directory), image = Icons.plane) + cmds.menuItem(label = "Poly Meshes", command = partial(Install.ToShelf_TogglePolymeshes, self.directory), image = Icons.polyMesh) + cmds.menuItem(label = "Shadows", command = partial(Install.ToShelf_ToggleShadows, self.directory), image = Icons.shadows) + cmds.menuItem(label = "Strokes", command = partial(Install.ToShelf_ToggleStrokes, self.directory), image = Icons.stroke) + cmds.menuItem(label = "Subdiv Surfaces", command = partial(Install.ToShelf_ToggleSubdivSurfaces, self.directory)) + cmds.menuItem(label = "Textures", command = partial(Install.ToShelf_ToggleTextures, self.directory)) cmds.setParent('..', menu = True) cmds.menuItem(dividerLabel = "TOOLS - Locators", divider = True) diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 452f6d0..1f4167c 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -59,7 +59,36 @@ class Presets: runCreateResetButton = pathInstall + "\n" + "install.CreateResetButton()" # TOGGLES + # runToggleAllObjects = pathToggles + "\n" + "toggles.ToggleAllObjects()" + runToggleCameras = pathToggles + "\n" + "toggles.ToggleCameras()" + runToggleControlVertices = pathToggles + "\n" + "toggles.ToggleControlVertices()" + runToggleDeformers = pathToggles + "\n" + "toggles.ToggleDeformers()" + runToggleDimensions = pathToggles + "\n" + "toggles.ToggleDimensions()" + runToggleDynamicConstraints = pathToggles + "\n" + "toggles.ToggleDynamicConstraints()" + runToggleDynamics = pathToggles + "\n" + "toggles.ToggleDynamics()" + runToggleFluids = pathToggles + "\n" + "toggles.ToggleFluids()" + runToggleFollicles = pathToggles + "\n" + "toggles.ToggleFollicles()" + runToggleGrid = pathToggles + "\n" + "toggles.ToggleGrid()" + runToggleHairSystems = pathToggles + "\n" + "toggles.ToggleHairSystems()" + runToggleHandles = pathToggles + "\n" + "toggles.ToggleHandles()" + runToggleHulls = pathToggles + "\n" + "toggles.ToggleHulls()" + runToggleIkHandles = pathToggles + "\n" + "toggles.ToggleIkHandles()" runToggleJoints = pathToggles + "\n" + "toggles.ToggleJoints()" + runToggleLights = pathToggles + "\n" + "toggles.ToggleLights()" + runToggleLocators = pathToggles + "\n" + "toggles.ToggleLocators()" + runToggleManipulators = pathToggles + "\n" + "toggles.ToggleManipulators()" + runToggleNCloths = pathToggles + "\n" + "toggles.ToggleNCloths()" + runToggleNParticles = pathToggles + "\n" + "toggles.ToggleNParticles()" + runToggleNRigids = pathToggles + "\n" + "toggles.ToggleNRigids()" + runToggleNurbsCurves = pathToggles + "\n" + "toggles.ToggleNurbsCurves()" + runToggleNurbsSurfaces = pathToggles + "\n" + "toggles.ToggleNurbsSurfaces()" + runTogglePivots = pathToggles + "\n" + "toggles.TogglePivots()" + runTogglePlanes = pathToggles + "\n" + "toggles.TogglePlanes()" + runTogglePolymeshes = pathToggles + "\n" + "toggles.TogglePolymeshes()" + runToggleShadows = pathToggles + "\n" + "toggles.ToggleShadows()" + runToggleStrokes = pathToggles + "\n" + "toggles.ToggleStrokes()" + runToggleSubdivSurfaces = pathToggles + "\n" + "toggles.ToggleSubdivSurfaces()" + runToggleTextures = pathToggles + "\n" + "toggles.ToggleTextures()" # LOCATORS runLocatorsSizeScale = pathLocators + "\n" + "locators.SelectedLocatorsSizeScale" @@ -150,15 +179,46 @@ def ToShelf_ReloadScene(path, *args): def ToShelf_ExitMaya(path, *args): MoveToShelf(path, Presets.runExitMaya, "ExitMaya", "Exit") + # UTILS def ToShelf_SelectHierarchy(path, *args): MoveToShelf(path, Presets.runSelectHierarchy, "SelectHierarchy", "SelHi") def ToShelf_CreateResetButton(path, *args): MoveToShelf(path, Presets.runCreateResetButton, "CreateResetButton", "Reset") + # TOGGLES -def ToShelf_ToggleJoints(path, *args): - MoveToShelf(path, Presets.runToggleJoints, "ToggleJoints", "tglJoints") +# def ToShelf_ToggleAllObjects(path, *args): MoveToShelf(path, Presets.runToggleAllObjects, "ToggleAllObjects", "tglAllObjects") +def ToShelf_ToggleCameras(path, *args): MoveToShelf(path, Presets.runToggleCameras, "ToggleCameras", "tglCameras") +def ToShelf_ToggleControlVertices(path, *args): MoveToShelf(path, Presets.runToggleControlVertices, "ToggleControlVertices", "tglControlVertices") +def ToShelf_ToggleDeformers(path, *args): MoveToShelf(path, Presets.runToggleDeformers, "ToggleDeformers", "tglDeformers") +def ToShelf_ToggleDimensions(path, *args): MoveToShelf(path, Presets.runToggleDimensions, "ToggleDimensions", "tglDimensions") +def ToShelf_ToggleDynamicConstraints(path, *args): MoveToShelf(path, Presets.runToggleDynamicConstraints, "ToggleDynamicConstraints", "tglDynamicConstraints") +def ToShelf_ToggleDynamics(path, *args): MoveToShelf(path, Presets.runToggleDynamics, "ToggleDynamics", "tglDynamics") +def ToShelf_ToggleFluids(path, *args): MoveToShelf(path, Presets.runToggleFluids, "ToggleFluids", "tglFluids") +def ToShelf_ToggleFollicles(path, *args): MoveToShelf(path, Presets.runToggleFollicles, "ToggleFollicles", "tglFollicles") +def ToShelf_ToggleGrid(path, *args): MoveToShelf(path, Presets.runToggleGrid, "ToggleGrid", "tglGrid") +def ToShelf_ToggleHairSystems(path, *args): MoveToShelf(path, Presets.runToggleHairSystems, "ToggleHairSystems", "tglHairSystems") +def ToShelf_ToggleHandles(path, *args): MoveToShelf(path, Presets.runToggleHandles, "ToggleHandles", "tglHandles") +def ToShelf_ToggleHulls(path, *args): MoveToShelf(path, Presets.runToggleHulls, "ToggleHulls", "tglHulls") +def ToShelf_ToggleIkHandles(path, *args): MoveToShelf(path, Presets.runToggleIkHandles, "ToggleIkHandles", "tglIkHandles") +def ToShelf_ToggleJoints(path, *args): MoveToShelf(path, Presets.runToggleJoints, "ToggleJoints", "tglJoints") +def ToShelf_ToggleLights(path, *args): MoveToShelf(path, Presets.runToggleLights, "ToggleLights", "tglLights") +def ToShelf_ToggleLocators(path, *args): MoveToShelf(path, Presets.runToggleLocators, "ToggleLocators", "tglLocators") +def ToShelf_ToggleManipulators(path, *args): MoveToShelf(path, Presets.runToggleManipulators, "ToggleManipulators", "tglManipulators") +def ToShelf_ToggleNCloths(path, *args): MoveToShelf(path, Presets.runToggleNCloths, "ToggleNCloths", "tglNCloths") +def ToShelf_ToggleNParticles(path, *args): MoveToShelf(path, Presets.runToggleNParticles, "ToggleNParticles", "tglNParticles") +def ToShelf_ToggleNRigids(path, *args): MoveToShelf(path, Presets.runToggleNRigids, "ToggleNRigids", "tglNRigids") +def ToShelf_ToggleNurbsCurves(path, *args): MoveToShelf(path, Presets.runToggleNurbsCurves, "ToggleNurbsCurves", "tglNurbsCurves") +def ToShelf_ToggleNurbsSurfaces(path, *args): MoveToShelf(path, Presets.runToggleNurbsSurfaces, "ToggleNurbsSurfaces", "tglNurbsSurfaces") +def ToShelf_TogglePivots(path, *args): MoveToShelf(path, Presets.runTogglePivots, "TogglePivots", "tglPivots") +def ToShelf_TogglePlanes(path, *args): MoveToShelf(path, Presets.runTogglePlanes, "TogglePlanes", "tglPlanes") +def ToShelf_TogglePolymeshes(path, *args): MoveToShelf(path, Presets.runTogglePolymeshes, "TogglePolymeshes", "tglPolymeshes") +def ToShelf_ToggleShadows(path, *args): MoveToShelf(path, Presets.runToggleShadows, "ToggleShadows", "tglShadows") +def ToShelf_ToggleStrokes(path, *args): MoveToShelf(path, Presets.runToggleStrokes, "ToggleStrokes", "tglStrokes") +def ToShelf_ToggleSubdivSurfaces(path, *args): MoveToShelf(path, Presets.runToggleSubdivSurfaces, "ToggleSubdivSurfaces", "tglSubdivSurfaces") +def ToShelf_ToggleTextures(path, *args): MoveToShelf(path, Presets.runToggleTextures, "ToggleTextures", "tglTextures") + # LOCATORS def ToShelf_LocatorsSizeScale50(path, *args): @@ -197,6 +257,7 @@ def ToShelf_LocatorsAim(path, name, rotateOnly, aimVector, *args): parameters = "(rotateOnly = {0}, aimVector = {1}, reverse = True)".format(rotateOnly, aimVector) MoveToShelf(path, Presets.runLocatorsAim + parameters, "LocatorsAim{0}".format(name), "Aim {0}".format(name)) + # BAKING def ToShelf_BakeClassic(path, *args): MoveToShelf(path, Presets.runBakeClassic + "(classic = True, preserveOutsideKeys = True)", "BakeClassic", "Bake") @@ -251,6 +312,7 @@ def ToShelf_EulerFilter(path, *args): def ToShelf_SetInfinity(path, mode, *args): MoveToShelf(path, Presets.runSetInfinity + "({0})".format(mode), "SetInfinity{0}".format(mode), "Inf{0}".format(mode)) + # TIMELINE def ToShelf_SetTimelineMinOut(path, *args): MoveToShelf(path, Presets.runSetTimeline + "(3)", "SetTimelineMinOut", "<<") @@ -267,6 +329,7 @@ def ToShelf_SetTimelineExpandIn(path, *args): def ToShelf_SetTimelineSet(path, *args): MoveToShelf(path, Presets.runSetTimeline + "(7)", "SetTimelineSet", "|<->|") + # RIGGING def ToShelf_Constraint(path, maintainOffset, parent, point, orient, scale, *args): if (maintainOffset): diff --git a/GETOOLS_SOURCE/utils/Toggles.py b/GETOOLS_SOURCE/utils/Toggles.py index 0fd2881..f75437d 100644 --- a/GETOOLS_SOURCE/utils/Toggles.py +++ b/GETOOLS_SOURCE/utils/Toggles.py @@ -24,13 +24,50 @@ import maya.cmds as cmds -# from ..utils import Selector +from ..values import Enums -def ToggleJoints(*args): # TODO make universal tool for other types +def Toggle(parameter): currentPanel = cmds.getPanel(withFocus = True) - checkJoints = cmds.modelEditor(currentPanel, query = True, joints = True) - cmds.modelEditor(currentPanel, edit = True, joints = not checkJoints) + checkModelEditor = cmds.modelEditor(currentPanel, exists = True) - print("Panel \"{0}\", Joints {1}".format(currentPanel, not checkJoints)) + if (not checkModelEditor): + cmds.warning("No Model Editor in panel \"{0}\"".format(currentPanel)) + return + + check = cmds.modelEditor(currentPanel, query = True, **{parameter: True}) + cmds.modelEditor(currentPanel, edit = True, **{parameter: not check}) + print("Panel \"{0}\", {1} {2}".format(currentPanel, parameter, not check)) + + +# def ToggleAllObjects(*args): Toggle(Enums.ModelEditor.allObjects) +def ToggleCameras(*args): Toggle(Enums.ModelEditor.cameras) +def ToggleControlVertices(*args): Toggle(Enums.ModelEditor.controlVertices) +def ToggleDeformers(*args): Toggle(Enums.ModelEditor.deformers) +def ToggleDimensions(*args): Toggle(Enums.ModelEditor.dimensions) +def ToggleDynamicConstraints(*args): Toggle(Enums.ModelEditor.dynamicConstraints) +def ToggleDynamics(*args): Toggle(Enums.ModelEditor.dynamics) +def ToggleFluids(*args): Toggle(Enums.ModelEditor.fluids) +def ToggleFollicles(*args): Toggle(Enums.ModelEditor.follicles) +def ToggleGrid(*args): Toggle(Enums.ModelEditor.grid) +def ToggleHairSystems(*args): Toggle(Enums.ModelEditor.hairSystems) +def ToggleHandles(*args): Toggle(Enums.ModelEditor.handles) +def ToggleHulls(*args): Toggle(Enums.ModelEditor.hulls) +def ToggleIkHandles(*args): Toggle(Enums.ModelEditor.ikHandles) +def ToggleJoints(*args): Toggle(Enums.ModelEditor.joints) +def ToggleLights(*args): Toggle(Enums.ModelEditor.lights) +def ToggleLocators(*args): Toggle(Enums.ModelEditor.locators) +def ToggleManipulators(*args): Toggle(Enums.ModelEditor.manipulators) +def ToggleNCloths(*args): Toggle(Enums.ModelEditor.nCloths) +def ToggleNParticles(*args): Toggle(Enums.ModelEditor.nParticles) +def ToggleNRigids(*args): Toggle(Enums.ModelEditor.nRigids) +def ToggleNurbsCurves(*args): Toggle(Enums.ModelEditor.nurbsCurves) +def ToggleNurbsSurfaces(*args): Toggle(Enums.ModelEditor.nurbsSurfaces) +def TogglePivots(*args): Toggle(Enums.ModelEditor.pivots) +def TogglePlanes(*args): Toggle(Enums.ModelEditor.planes) +def TogglePolymeshes(*args): Toggle(Enums.ModelEditor.polymeshes) +def ToggleShadows(*args): Toggle(Enums.ModelEditor.shadows) +def ToggleStrokes(*args): Toggle(Enums.ModelEditor.strokes) +def ToggleSubdivSurfaces(*args): Toggle(Enums.ModelEditor.subdivSurfaces) +def ToggleTextures(*args): Toggle(Enums.ModelEditor.textures) diff --git a/GETOOLS_SOURCE/values/Enums.py b/GETOOLS_SOURCE/values/Enums.py index 1956268..a9a202c 100644 --- a/GETOOLS_SOURCE/values/Enums.py +++ b/GETOOLS_SOURCE/values/Enums.py @@ -102,3 +102,36 @@ class Other: ".overrideEnabled" ".overrideDisplayType" + +class ModelEditor: + # allObjects = "allObjects" + cameras = "cameras" + controlVertices = "controlVertices" + deformers = "deformers" + dimensions = "dimensions" + dynamicConstraints = "dynamicConstraints" + dynamics = "dynamics" + fluids = "fluids" + follicles = "follicles" + grid = "grid" + hairSystems = "hairSystems" + handles = "handles" + hulls = "hulls" + ikHandles = "ikHandles" + joints = "joints" + lights = "lights" + locators = "locators" + manipulators = "manipulators" + nCloths = "nCloths" + nParticles = "nParticles" + nRigids = "nRigids" + nurbsCurves = "nurbsCurves" + nurbsSurfaces = "nurbsSurfaces" + pivots = "pivots" + planes = "planes" + polymeshes = "polymeshes" + shadows = "shadows" + strokes = "strokes" + subdivSurfaces = "subdivSurfaces" + textures = "textures" + diff --git a/GETOOLS_SOURCE/values/Icons.py b/GETOOLS_SOURCE/values/Icons.py index d95f2c9..a6f7f6d 100644 --- a/GETOOLS_SOURCE/values/Icons.py +++ b/GETOOLS_SOURCE/values/Icons.py @@ -35,22 +35,29 @@ arrowLeft = "arrowLeft.png" arrowRight = "arrowRight.png" arrowUp = "arrowUp.png" +blendshape = "blendShape.png" bookmark = "Bookmark.png" +camera = "camera.svg" color = "colorPresetSpectrum.png" confirm = "confirm.png" constraint = "out_normalConstraint.png" copy = "skinWeightCopy.png" cursor = "aselect.png" delete = "delete.png" +dynamicConstraint = "dynamicConstraint.svg" error = "error.png" expandLeft = "leftExpand.png" expandRight = "rightExpand.png" fileOpen = "fileOpen.png" fileSave = "fileSave.png" filter = "filter.png" +follicle = "follicle.svg" +grid = "grid.svg" +hairSystem = "hairSystem.svg" help = "help.png" helpLine = "help_line.png" home = "home.png" +ikHandle = "ikHandle.svg" itemDown = "item_down.png" itemUp = "item_up.png" joint = "kinJoint.png" @@ -61,27 +68,34 @@ lock = "lock.png" lockOff = "Lock_OFF.png" lockOn = "Lock_ON.png" +nCloth = "nCloth.svg" +nRigid = "nRigid.svg" nucleus = "nucleus.svg" +nurbsCurve = "nurbsCurve.svg" +nurbsSurface = "nurbsSurface.svg" off = "hyper_s_OFF.png" on = "hyper_s_ON.png" particle = "particle.svg" pin = "pinItem.png" pinInvert = "invertUVpinning.png" +plane = "plane.png" playblast = "playblast.png" plus = "addClip.png" +polyMesh = "polyMesh.png" reset = "menuIconReset.png" rotateCClockwise = "counterclockwise.png" rotateClockwise = "clockwise.png" settings = "advancedSettings.png" +shadows = "Shadows.png" +stroke = "stroke.svg" text = "polyType.png" visibleOff = "hidden.png" visibleOn = "visible.png" wait = "waitBusy.png" warning = "warningIcon.svg" world = "volumeSphere.png" -zoom = "zoom.png" -blendshape = "blendShape.png" wrap = "wrap.png" +zoom = "zoom.png" # TODO add icons sample window From e10dee362c59d13278b28981ef53ec22bf42a659 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 13:08:47 -0700 Subject: [PATCH 22/27] rework code install logic and cleanup --- GETOOLS_SOURCE/modules/GeneralWindow.py | 7 +- GETOOLS_SOURCE/utils/Blendshapes.py | 1 - GETOOLS_SOURCE/utils/Constraints.py | 1 - GETOOLS_SOURCE/utils/Deformers.py | 1 - GETOOLS_SOURCE/utils/Install.py | 305 ++++++++-------------- GETOOLS_SOURCE/utils/Layers.py | 2 - GETOOLS_SOURCE/utils/Locators.py | 1 - GETOOLS_SOURCE/utils/Other.py | 13 +- GETOOLS_SOURCE/utils/Selector.py | 6 +- GETOOLS_SOURCE/utils/Skinning.py | 4 +- GETOOLS_SOURCE/utils/Toggles.py | 2 - GETOOLS_SOURCE/values/CodeSamples.py | 329 ++++++++++++++++++++++++ GETOOLS_SOURCE/values/Enums.py | 2 +- 13 files changed, 450 insertions(+), 224 deletions(-) create mode 100644 GETOOLS_SOURCE/values/CodeSamples.py diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 82064dd..9efd72a 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -460,14 +460,17 @@ def LayoutExperimental(self, parentLayout): cmds.menuItem(label = "Right-Click test") countOffsets = 3 - cmds.gridLayout(numberOfColumns = countOffsets, cellWidth = Settings.windowWidthMargin / countOffsets, cellHeight = Settings.lineHeight) - + cmds.gridLayout(parent = self.frameExperimental, numberOfColumns = countOffsets, cellWidth = Settings.windowWidthMargin / countOffsets, cellHeight = Settings.lineHeight) cmds.button(label = "Trails Create", command = MotionTrail.Create, backgroundColor = Colors.orange10) cmds.button(label = "Trails Select", command = MotionTrail.Select, backgroundColor = Colors.orange50) cmds.button(label = "Trails Delete", command = MotionTrail.Delete, backgroundColor = Colors.orange100) # cmds.popupMenu() # cmds.menuItem(label = "Select", command = MotionTrail.Select) # cmds.menuItem(label = "Delete", command = MotionTrail.Delete) + + # countOffsets = 1 + # cmds.gridLayout(parent = self.frameExperimental, numberOfColumns = countOffsets, cellWidth = Settings.windowWidthMargin / countOffsets, cellHeight = Settings.lineHeight) + # cmds.button(label = "Print function", command = Install.TEST_INSPECT) pass # WINDOW diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index ced4513..2efe31a 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -27,7 +27,6 @@ from ..utils import Selector - def GetBlendshapeNodeFromModel(model): if (model == None): return None diff --git a/GETOOLS_SOURCE/utils/Constraints.py b/GETOOLS_SOURCE/utils/Constraints.py index 05607d1..674e387 100644 --- a/GETOOLS_SOURCE/utils/Constraints.py +++ b/GETOOLS_SOURCE/utils/Constraints.py @@ -25,7 +25,6 @@ import maya.cmds as cmds from ..utils import Selector - from ..values import Enums def ConstrainSelectedToLastObject(reverse=False, maintainOffset=True, parent=True, point=False, orient=False, scale=False, aim=False, weight=1): diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index 748f1d5..05d2644 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -34,7 +34,6 @@ dropoff = 4 smoothness = 0 - def WrapsCreateOnList(elements): if (len(elements) < 2): cmds.warning("Need at least 2 objects for Wrap") diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index 1f4167c..b926bdb 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -25,122 +25,29 @@ import os import sys +import inspect from ..utils import Shelf - +from ..values import CodeSamples from ..values import Enums -class Presets: - pathGeneral = "import GETOOLS_SOURCE.modules.GeneralWindow as gtwindow" - pathAnimation = "import GETOOLS_SOURCE.utils.Animation as animation" - pathBaker = "import GETOOLS_SOURCE.utils.Baker as baker" - pathBlendshapes = "import GETOOLS_SOURCE.utils.Blendshapes as blendshapes" - pathConstraints = "import GETOOLS_SOURCE.utils.Constraints as constraints" - pathDeformers = "import GETOOLS_SOURCE.utils.Deformers as deformers" - pathInstall = "import GETOOLS_SOURCE.utils.Install as install" - pathLocators = "import GETOOLS_SOURCE.utils.Locators as locators" - pathMotionTrail = "import GETOOLS_SOURCE.utils.MotionTrail as mtrail" - pathOther = "import GETOOLS_SOURCE.utils.Other as other" - pathScene = "import GETOOLS_SOURCE.utils.Scene as scene" - pathSelector = "import GETOOLS_SOURCE.utils.Selector as selector" - pathSkinning = "import GETOOLS_SOURCE.utils.Skinning as skinning" - pathTimeline = "import GETOOLS_SOURCE.utils.Timeline as timeline" - pathToggles = "import GETOOLS_SOURCE.utils.Toggles as toggles" - - # GENERAL - runGeneralWindow = pathGeneral + "\n" + "gtwindow.GeneralWindow().RUN_DOCKED()" - - # FILE - runSceneReload = pathScene + "\n" + "scene.Reload()" - runExitMaya = pathScene + "\n" + "scene.ExitMaya()" - - # UTILS - runSelectHierarchy = pathSelector + "\n" + "selector.SelectHierarchy()" - runCreateResetButton = pathInstall + "\n" + "install.CreateResetButton()" - - # TOGGLES - # runToggleAllObjects = pathToggles + "\n" + "toggles.ToggleAllObjects()" - runToggleCameras = pathToggles + "\n" + "toggles.ToggleCameras()" - runToggleControlVertices = pathToggles + "\n" + "toggles.ToggleControlVertices()" - runToggleDeformers = pathToggles + "\n" + "toggles.ToggleDeformers()" - runToggleDimensions = pathToggles + "\n" + "toggles.ToggleDimensions()" - runToggleDynamicConstraints = pathToggles + "\n" + "toggles.ToggleDynamicConstraints()" - runToggleDynamics = pathToggles + "\n" + "toggles.ToggleDynamics()" - runToggleFluids = pathToggles + "\n" + "toggles.ToggleFluids()" - runToggleFollicles = pathToggles + "\n" + "toggles.ToggleFollicles()" - runToggleGrid = pathToggles + "\n" + "toggles.ToggleGrid()" - runToggleHairSystems = pathToggles + "\n" + "toggles.ToggleHairSystems()" - runToggleHandles = pathToggles + "\n" + "toggles.ToggleHandles()" - runToggleHulls = pathToggles + "\n" + "toggles.ToggleHulls()" - runToggleIkHandles = pathToggles + "\n" + "toggles.ToggleIkHandles()" - runToggleJoints = pathToggles + "\n" + "toggles.ToggleJoints()" - runToggleLights = pathToggles + "\n" + "toggles.ToggleLights()" - runToggleLocators = pathToggles + "\n" + "toggles.ToggleLocators()" - runToggleManipulators = pathToggles + "\n" + "toggles.ToggleManipulators()" - runToggleNCloths = pathToggles + "\n" + "toggles.ToggleNCloths()" - runToggleNParticles = pathToggles + "\n" + "toggles.ToggleNParticles()" - runToggleNRigids = pathToggles + "\n" + "toggles.ToggleNRigids()" - runToggleNurbsCurves = pathToggles + "\n" + "toggles.ToggleNurbsCurves()" - runToggleNurbsSurfaces = pathToggles + "\n" + "toggles.ToggleNurbsSurfaces()" - runTogglePivots = pathToggles + "\n" + "toggles.TogglePivots()" - runTogglePlanes = pathToggles + "\n" + "toggles.TogglePlanes()" - runTogglePolymeshes = pathToggles + "\n" + "toggles.TogglePolymeshes()" - runToggleShadows = pathToggles + "\n" + "toggles.ToggleShadows()" - runToggleStrokes = pathToggles + "\n" + "toggles.ToggleStrokes()" - runToggleSubdivSurfaces = pathToggles + "\n" + "toggles.ToggleSubdivSurfaces()" - runToggleTextures = pathToggles + "\n" + "toggles.ToggleTextures()" - - # LOCATORS - runLocatorsSizeScale = pathLocators + "\n" + "locators.SelectedLocatorsSizeScale" - runLocatorsSizeSet = pathLocators + "\n" + "locators.SelectedLocatorsSizeSet" - runLocatorCreate = pathLocators + "\n" + "locators.Create()" - runLocatorsMatch = pathLocators + "\n" + "locators.CreateOnSelected(constraint = False)" - runLocatorsParent = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True)" - runLocatorsPin = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = True)" - runLocatorsPinWithoutReverse = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True)" - runLocatorsPinPos = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = False)" - runLocatorsPinRot = pathLocators + "\n" + "locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = False, constrainRotate = True)" - runLocatorsRelative = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True, skipLastReverse = False)" - runLocatorsRelativeSkipLast = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True)" - runLocatorsRelativeWithoutReverse = pathLocators + "\n" + "locators.CreateAndBakeAsChildrenFromLastSelected()" - runLocatorsAim = pathLocators + "\n" + "locators.CreateOnSelectedAim" - - # BAKING - runBakeClassic = pathBaker + "\n" + "baker.BakeSelected" - runBakeCustom = pathBaker + "\n" + "baker.BakeSelected" - runBakeByLast = pathBaker + "\n" + "baker.BakeSelectedByLastObject" - runBakeByWorld = pathBaker + "\n" + "baker.BakeSelectedByWorld" - - # ANIMATION - runAnimOffset = pathAnimation + "\n" + "animation.OffsetObjects" - runDeleteKeys = pathAnimation + "\n" + "animation.DeleteKeys(True)" - runDeleteNonkeyable = pathAnimation + "\n" + "animation.DeleteKeysNonkeyable()" - runDeleteStatic = pathAnimation + "\n" + "animation.DeleteStaticCurves()" - runEulerFilter = pathAnimation + "\n" + "animation.FilterCurve()" - runSetInfinity = pathAnimation + "\n" + "animation.SetInfinity" - runSetTimeline = pathTimeline + "\n" + "timeline.SetTime" - - # RIGGING - runConstraint = pathConstraints + "\n" + "constraints.ConstrainSelectedToLastObject" - runDeleteConstraints = pathConstraints + "\n" + "constraints.DeleteConstraintsOnSelected()" - runDisconnectTargets = pathConstraints + "\n" + "constraints.DisconnectTargetsFromConstraintOnSelected()" - runRotateOrder = pathOther + "\n" + "other.RotateOrderVisibility" - runSegmentScaleCompensateCompensate = pathOther + "\n" + "other.SegmentScaleCompensate" - runJointDrawStyle = pathOther + "\n" + "other.JointDrawStyle" - runCopySkin = pathSkinning + "\n" + "skinning.CopySkinWeightsFromLastMesh()" - runWrapsCreate = pathDeformers + "\n" + "deformers.WrapsCreateOnSelected()" - - # runWrapsConvert = pathDeformers + "\n" + "ndeformers.WrapsConvertFromSelected()" # TODO - runBlendshapesReconstruct = pathDeformers + "\n" + "deformers.BlendshapesReconstruction()" - runBlendshapesZeroWeights = pathBlendshapes + "\n" + "blendshapes.ZeroBlendshapeWeightsOnSelected()" - - # EXPERIMENTAL - runMotionTrailCreate = pathMotionTrail + "\n" + "mtrail.Create()" - runMotionTrailSelect = pathMotionTrail + "\n" + "mtrail.Select()" - runMotionTrailDelete = pathMotionTrail + "\n" + "mtrail.Delete()" - - # LOGIC +def ReadFunctionAsString(func): + source = inspect.getsource(func) + + # Remove first line and indents in code body + lines = source.split('\n') + lines = lines[1:-1] + lines = [line.lstrip() for line in lines] + linesCount = len(lines) + result = "" + + for i in range(linesCount): + result = result + lines[i] + if (i < linesCount - 1): + result = result + "\n" + + return result def AddPathToEnvironment(path, *args): if not os.path.exists(path): raise IOError(r'The source path {0} does not exist!'.format(path)) @@ -172,101 +79,96 @@ def MoveToShelf(path, tool, label, labelImage, *args): labelImage = labelImage ) - # FILE def ToShelf_ReloadScene(path, *args): - MoveToShelf(path, Presets.runSceneReload, "SceneReload", "Reload") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SceneReload), "SceneReload", "Reload") def ToShelf_ExitMaya(path, *args): - MoveToShelf(path, Presets.runExitMaya, "ExitMaya", "Exit") - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.ExitMaya), "ExitMaya", "Exit") # UTILS def ToShelf_SelectHierarchy(path, *args): - MoveToShelf(path, Presets.runSelectHierarchy, "SelectHierarchy", "SelHi") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SelectHierarchy), "SelectHierarchy", "SelHi") def ToShelf_CreateResetButton(path, *args): - MoveToShelf(path, Presets.runCreateResetButton, "CreateResetButton", "Reset") - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.CreateResetButton), "CreateResetButton", "Reset") # TOGGLES -# def ToShelf_ToggleAllObjects(path, *args): MoveToShelf(path, Presets.runToggleAllObjects, "ToggleAllObjects", "tglAllObjects") -def ToShelf_ToggleCameras(path, *args): MoveToShelf(path, Presets.runToggleCameras, "ToggleCameras", "tglCameras") -def ToShelf_ToggleControlVertices(path, *args): MoveToShelf(path, Presets.runToggleControlVertices, "ToggleControlVertices", "tglControlVertices") -def ToShelf_ToggleDeformers(path, *args): MoveToShelf(path, Presets.runToggleDeformers, "ToggleDeformers", "tglDeformers") -def ToShelf_ToggleDimensions(path, *args): MoveToShelf(path, Presets.runToggleDimensions, "ToggleDimensions", "tglDimensions") -def ToShelf_ToggleDynamicConstraints(path, *args): MoveToShelf(path, Presets.runToggleDynamicConstraints, "ToggleDynamicConstraints", "tglDynamicConstraints") -def ToShelf_ToggleDynamics(path, *args): MoveToShelf(path, Presets.runToggleDynamics, "ToggleDynamics", "tglDynamics") -def ToShelf_ToggleFluids(path, *args): MoveToShelf(path, Presets.runToggleFluids, "ToggleFluids", "tglFluids") -def ToShelf_ToggleFollicles(path, *args): MoveToShelf(path, Presets.runToggleFollicles, "ToggleFollicles", "tglFollicles") -def ToShelf_ToggleGrid(path, *args): MoveToShelf(path, Presets.runToggleGrid, "ToggleGrid", "tglGrid") -def ToShelf_ToggleHairSystems(path, *args): MoveToShelf(path, Presets.runToggleHairSystems, "ToggleHairSystems", "tglHairSystems") -def ToShelf_ToggleHandles(path, *args): MoveToShelf(path, Presets.runToggleHandles, "ToggleHandles", "tglHandles") -def ToShelf_ToggleHulls(path, *args): MoveToShelf(path, Presets.runToggleHulls, "ToggleHulls", "tglHulls") -def ToShelf_ToggleIkHandles(path, *args): MoveToShelf(path, Presets.runToggleIkHandles, "ToggleIkHandles", "tglIkHandles") -def ToShelf_ToggleJoints(path, *args): MoveToShelf(path, Presets.runToggleJoints, "ToggleJoints", "tglJoints") -def ToShelf_ToggleLights(path, *args): MoveToShelf(path, Presets.runToggleLights, "ToggleLights", "tglLights") -def ToShelf_ToggleLocators(path, *args): MoveToShelf(path, Presets.runToggleLocators, "ToggleLocators", "tglLocators") -def ToShelf_ToggleManipulators(path, *args): MoveToShelf(path, Presets.runToggleManipulators, "ToggleManipulators", "tglManipulators") -def ToShelf_ToggleNCloths(path, *args): MoveToShelf(path, Presets.runToggleNCloths, "ToggleNCloths", "tglNCloths") -def ToShelf_ToggleNParticles(path, *args): MoveToShelf(path, Presets.runToggleNParticles, "ToggleNParticles", "tglNParticles") -def ToShelf_ToggleNRigids(path, *args): MoveToShelf(path, Presets.runToggleNRigids, "ToggleNRigids", "tglNRigids") -def ToShelf_ToggleNurbsCurves(path, *args): MoveToShelf(path, Presets.runToggleNurbsCurves, "ToggleNurbsCurves", "tglNurbsCurves") -def ToShelf_ToggleNurbsSurfaces(path, *args): MoveToShelf(path, Presets.runToggleNurbsSurfaces, "ToggleNurbsSurfaces", "tglNurbsSurfaces") -def ToShelf_TogglePivots(path, *args): MoveToShelf(path, Presets.runTogglePivots, "TogglePivots", "tglPivots") -def ToShelf_TogglePlanes(path, *args): MoveToShelf(path, Presets.runTogglePlanes, "TogglePlanes", "tglPlanes") -def ToShelf_TogglePolymeshes(path, *args): MoveToShelf(path, Presets.runTogglePolymeshes, "TogglePolymeshes", "tglPolymeshes") -def ToShelf_ToggleShadows(path, *args): MoveToShelf(path, Presets.runToggleShadows, "ToggleShadows", "tglShadows") -def ToShelf_ToggleStrokes(path, *args): MoveToShelf(path, Presets.runToggleStrokes, "ToggleStrokes", "tglStrokes") -def ToShelf_ToggleSubdivSurfaces(path, *args): MoveToShelf(path, Presets.runToggleSubdivSurfaces, "ToggleSubdivSurfaces", "tglSubdivSurfaces") -def ToShelf_ToggleTextures(path, *args): MoveToShelf(path, Presets.runToggleTextures, "ToggleTextures", "tglTextures") - +# def ToShelf_ToggleAllObjects(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.), "ToggleAllObjects", "tglAllObjects") # TODO +def ToShelf_ToggleCameras(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleCameras), "ToggleCameras", "tglCameras") +def ToShelf_ToggleControlVertices(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleControlVertices), "ToggleControlVertices", "tglControlVertices") +def ToShelf_ToggleDeformers(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleDeformers), "ToggleDeformers", "tglDeformers") +def ToShelf_ToggleDimensions(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleDimensions), "ToggleDimensions", "tglDimensions") +def ToShelf_ToggleDynamicConstraints(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleDynamicConstraints), "ToggleDynamicConstraints", "tglDynamicConstraints") +def ToShelf_ToggleDynamics(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleDynamics), "ToggleDynamics", "tglDynamics") +def ToShelf_ToggleFluids(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleFluids), "ToggleFluids", "tglFluids") +def ToShelf_ToggleFollicles(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleFollicles), "ToggleFollicles", "tglFollicles") +def ToShelf_ToggleGrid(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleGrid), "ToggleGrid", "tglGrid") +def ToShelf_ToggleHairSystems(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleHairSystems), "ToggleHairSystems", "tglHairSystems") +def ToShelf_ToggleHandles(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleHandles), "ToggleHandles", "tglHandles") +def ToShelf_ToggleHulls(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleHulls), "ToggleHulls", "tglHulls") +def ToShelf_ToggleIkHandles(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleIkHandles), "ToggleIkHandles", "tglIkHandles") +def ToShelf_ToggleJoints(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleJoints), "ToggleJoints", "tglJoints") +def ToShelf_ToggleLights(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleLights), "ToggleLights", "tglLights") +def ToShelf_ToggleLocators(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleLocators), "ToggleLocators", "tglLocators") +def ToShelf_ToggleManipulators(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleManipulators), "ToggleManipulators", "tglManipulators") +def ToShelf_ToggleNCloths(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleNCloths), "ToggleNCloths", "tglNCloths") +def ToShelf_ToggleNParticles(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleNParticles), "ToggleNParticles", "tglNParticles") +def ToShelf_ToggleNRigids(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleNRigids), "ToggleNRigids", "tglNRigids") +def ToShelf_ToggleNurbsCurves(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleNurbsCurves), "ToggleNurbsCurves", "tglNurbsCurves") +def ToShelf_ToggleNurbsSurfaces(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleNurbsSurfaces), "ToggleNurbsSurfaces", "tglNurbsSurfaces") +def ToShelf_TogglePivots(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.TogglePivots), "TogglePivots", "tglPivots") +def ToShelf_TogglePlanes(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.TogglePlanes), "TogglePlanes", "tglPlanes") +def ToShelf_TogglePolymeshes(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.TogglePolymeshes), "TogglePolymeshes", "tglPolymeshes") +def ToShelf_ToggleShadows(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleShadows), "ToggleShadows", "tglShadows") +def ToShelf_ToggleStrokes(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleStrokes), "ToggleStrokes", "tglStrokes") +def ToShelf_ToggleSubdivSurfaces(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleSubdivSurfaces), "ToggleSubdivSurfaces", "tglSubdivSurfaces") +def ToShelf_ToggleTextures(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.ToggleTextures), "ToggleTextures", "tglTextures") # LOCATORS def ToShelf_LocatorsSizeScale50(path, *args): - MoveToShelf(path, Presets.runLocatorsSizeScale + "(0.5)", "LocatorsSizeScale50", "L50%") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsSizeScale) + "(0.5)", "LocatorsSizeScale50", "L50%") def ToShelf_LocatorsSizeScale90(path, *args): - MoveToShelf(path, Presets.runLocatorsSizeScale + "(0.9)", "LocatorsSizeScale90", "L90%") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsSizeScale) + "(0.9)", "LocatorsSizeScale90", "L90%") def ToShelf_LocatorsSizeScale110(path, *args): - MoveToShelf(path, Presets.runLocatorsSizeScale + "(1.1)", "LocatorsSizeScale110", "L110%") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsSizeScale) + "(1.1)", "LocatorsSizeScale110", "L110%") def ToShelf_LocatorsSizeScale200(path, *args): - MoveToShelf(path, Presets.runLocatorsSizeScale + "(2.0)", "LocatorsSizeScale200", "L200%") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsSizeScale) + "(2.0)", "LocatorsSizeScale200", "L200%") def ToShelf_LocatorCreate(path, *args): - MoveToShelf(path, Presets.runLocatorCreate, "LocatorCreate", "Loc") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorCreate), "LocatorCreate", "Loc") def ToShelf_LocatorsMatch(path, *args): - MoveToShelf(path, Presets.runLocatorsMatch, "LocatorsMatch", "LocMatch") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsMatch), "LocatorsMatch", "LocMatch") def ToShelf_LocatorsParent(path, *args): - MoveToShelf(path, Presets.runLocatorsParent, "LocatorsParent", "LocParent") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsParent), "LocatorsParent", "LocParent") def ToShelf_LocatorsPin(path, *args): - MoveToShelf(path, Presets.runLocatorsPin, "LocatorsPin", "Pin") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsPin), "LocatorsPin", "Pin") def ToShelf_LocatorsPinWithoutReverse(path, *args): - MoveToShelf(path, Presets.runLocatorsPinWithoutReverse, "LocatorsPinWithoutReverse", "Pin-") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsPinWithoutReverse), "LocatorsPinWithoutReverse", "Pin-") def ToShelf_LocatorsPinPos(path, *args): - MoveToShelf(path, Presets.runLocatorsPinPos, "LocatorsPinPos", "P-Pos") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsPinPos), "LocatorsPinPos", "P-Pos") def ToShelf_LocatorsPinRot(path, *args): - MoveToShelf(path, Presets.runLocatorsPinRot, "LocatorsPinRot", "P-Rot") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsPinRot), "LocatorsPinRot", "P-Rot") def ToShelf_LocatorsRelative(path, *args): - MoveToShelf(path, Presets.runLocatorsRelative, "Relative", "Rel") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsRelative), "Relative", "Rel") def ToShelf_LocatorsRelativeSkipLast(path, *args): - MoveToShelf(path, Presets.runLocatorsRelativeSkipLast, "RelativeSkipLast", "Rel-1") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsRelativeSkipLast), "RelativeSkipLast", "Rel-1") def ToShelf_LocatorsRelativeWithoutReverse(path, *args): - MoveToShelf(path, Presets.runLocatorsRelativeWithoutReverse, "RelativeWithoutReverse", "Rel-") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsRelativeWithoutReverse), "RelativeWithoutReverse", "Rel-") def ToShelf_LocatorsAim(path, name, rotateOnly, aimVector, *args): parameters = "(rotateOnly = {0}, aimVector = {1}, reverse = True)".format(rotateOnly, aimVector) - MoveToShelf(path, Presets.runLocatorsAim + parameters, "LocatorsAim{0}".format(name), "Aim {0}".format(name)) - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.LocatorsAim) + parameters, "LocatorsAim{0}".format(name), "Aim {0}".format(name)) # BAKING def ToShelf_BakeClassic(path, *args): - MoveToShelf(path, Presets.runBakeClassic + "(classic = True, preserveOutsideKeys = True)", "BakeClassic", "Bake") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeClassic) + "(classic = True, preserveOutsideKeys = True)", "BakeClassic", "Bake") def ToShelf_BakeClassicCutOut(path, *args): - MoveToShelf(path, Presets.runBakeClassic + "(classic = True, preserveOutsideKeys = False)", "BakeClassicCutOut", "BakeCut") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeClassic) + "(classic = True, preserveOutsideKeys = False)", "BakeClassicCutOut", "BakeCut") def ToShelf_BakeCustom(path, *args): - MoveToShelf(path, Presets.runBakeCustom + "(classic = False, preserveOutsideKeys = True, selectedRange = True, channelBox = True)", "BakeCustom", "BakeC") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeCustom) + "(classic = False, preserveOutsideKeys = True, selectedRange = True, channelBox = True)", "BakeCustom", "BakeC") def ToShelf_BakeCustomCutOut(path, *args): - MoveToShelf(path, Presets.runBakeCustom + "(classic = False, preserveOutsideKeys = False, selectedRange = True, channelBox = True)", "BakeCustomCutOut", "BakeCCut") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeCustom) + "(classic = False, preserveOutsideKeys = False, selectedRange = True, channelBox = True)", "BakeCustomCutOut", "BakeCCut") def ToShelf_BakeByLast(path, translate, rotate, *args): if (translate and rotate): @@ -280,7 +182,7 @@ def ToShelf_BakeByLast(path, translate, rotate, *args): suffix = "ROT" attributes = Enums.Attributes.rotateShort parameters = "(selectedRange = True, channelBox = False, attributes = {0})".format(attributes) - MoveToShelf(path, Presets.runBakeByLast + parameters, "BakeByLast{0}".format(suffix), "BL{0}".format(suffix)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeByLast) + parameters, "BakeByLast{0}".format(suffix), "BL{0}".format(suffix)) def ToShelf_BakeByWorld(path, translate, rotate, *args): if (translate and rotate): suffix = "" @@ -293,42 +195,39 @@ def ToShelf_BakeByWorld(path, translate, rotate, *args): suffix = "ROT" attributes = Enums.Attributes.rotateShort parameters = "(selectedRange = True, channelBox = False, attributes = {0})".format(attributes) - MoveToShelf(path, Presets.runBakeByWorld + parameters, "BakeByWorld{0}".format(suffix), "BW{0}".format(suffix)) - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BakeByWorld) + parameters, "BakeByWorld{0}".format(suffix), "BW{0}".format(suffix)) # ANIMATION def ToShelf_AnimOffset(path, direction, time, *args): - MoveToShelf(path, Presets.runAnimOffset + "({0}, {1})".format(direction, time), "AnimOffset_{0}_{1}".format(direction, time), "AO{0}_{1}".format(direction, time)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.AnimOffset) + "({0}, {1})".format(direction, time), "AnimOffset_{0}_{1}".format(direction, time), "AO{0}_{1}".format(direction, time)) def ToShelf_DeleteKeys(path, *args): - MoveToShelf(path, Presets.runDeleteKeys, "DeleteKeys", "DKeys") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.DeleteKeys), "DeleteKeys", "DKeys") def ToShelf_DeleteNonkeyable(path, *args): - MoveToShelf(path, Presets.runDeleteNonkeyable, "DeleteNonkeyable", "DNonkeyable") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.DeleteNonkeyable), "DeleteNonkeyable", "DNonkeyable") def ToShelf_DeleteStatic(path, *args): - MoveToShelf(path, Presets.runDeleteStatic, "DeleteStatic", "DStatic") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.DeleteStatic), "DeleteStatic", "DStatic") def ToShelf_EulerFilter(path, *args): - MoveToShelf(path, Presets.runEulerFilter, "EulerFilter", "Euler") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.EulerFilter), "EulerFilter", "Euler") def ToShelf_SetInfinity(path, mode, *args): - MoveToShelf(path, Presets.runSetInfinity + "({0})".format(mode), "SetInfinity{0}".format(mode), "Inf{0}".format(mode)) - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetInfinity) + "({0})".format(mode), "SetInfinity{0}".format(mode), "Inf{0}".format(mode)) # TIMELINE def ToShelf_SetTimelineMinOut(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(3)", "SetTimelineMinOut", "<<") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(3)", "SetTimelineMinOut", "<<") def ToShelf_SetTimelineMinIn(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(1)", "SetTimelineMinIn", "<-") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(1)", "SetTimelineMinIn", "<-") def ToShelf_SetTimelineMaxIn(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(2)", "SetTimelineMaxIn", "->") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(2)", "SetTimelineMaxIn", "->") def ToShelf_SetTimelineMaxOut(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(4)", "SetTimelineMaxOut", ">>") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(4)", "SetTimelineMaxOut", ">>") def ToShelf_SetTimelineExpandOut(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(5)", "SetTimelineExpandOut", "<->") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(5)", "SetTimelineExpandOut", "<->") def ToShelf_SetTimelineExpandIn(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(6)", "SetTimelineExpandIn", ">-<") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(6)", "SetTimelineExpandIn", ">-<") def ToShelf_SetTimelineSet(path, *args): - MoveToShelf(path, Presets.runSetTimeline + "(7)", "SetTimelineSet", "|<->|") - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(7)", "SetTimelineSet", "|<->|") # RIGGING def ToShelf_Constraint(path, maintainOffset, parent, point, orient, scale, *args): @@ -348,40 +247,38 @@ def ToShelf_Constraint(path, maintainOffset, parent, point, orient, scale, *args suffix = suffixMaintain + suffix - MoveToShelf(path, Presets.runConstraint + "(maintainOffset = {0}, parent = {1}, point = {2}, orient = {3}, scale = {4})".format(maintainOffset, parent, point, orient, scale), "Constraint{0}".format(suffix), "C{0}".format(suffix)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.Constraint) + "(maintainOffset = {0}, parent = {1}, point = {2}, orient = {3}, scale = {4})".format(maintainOffset, parent, point, orient, scale), "Constraint{0}".format(suffix), "C{0}".format(suffix)) def ToShelf_DeleteConstraints(path, *args): - MoveToShelf(path, Presets.runDeleteConstraints, "DeleteConstraints", "DeleteConstraints") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.DeleteConstraints), "DeleteConstraints", "DeleteConstraints") def ToShelf_DisconnectTargets(path, *args): - MoveToShelf(path, Presets.runDisconnectTargets, "DisconnectTargets", "Disconnect") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.DisconnectTargets), "DisconnectTargets", "Disconnect") def ToShelf_RotateOrder(path, mode, *args): - MoveToShelf(path, Presets.runRotateOrder + "({0})".format(mode), "RotateOrder{0}".format(mode), "RO{0}".format(mode)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.RotateOrder) + "({0})".format(mode), "RotateOrder{0}".format(mode), "RO{0}".format(mode)) def ToShelf_SegmentScaleCompensate(path, mode, *args): - MoveToShelf(path, Presets.runSegmentScaleCompensateCompensate + "({0})".format(mode), "SegmentScaleCompensate{0}".format(mode), "SSC{0}".format(mode)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SegmentScaleCompensate) + "({0})".format(mode), "SegmentScaleCompensate{0}".format(mode), "SSC{0}".format(mode)) def ToShelf_JointDrawStyle(path, mode, *args): - MoveToShelf(path, Presets.runJointDrawStyle + "({0})".format(mode), "JointDrawStyle{0}".format(mode), "J{0}".format(mode)) + MoveToShelf(path, ReadFunctionAsString(CodeSamples.JointDrawStyle) + "({0})".format(mode), "JointDrawStyle{0}".format(mode), "J{0}".format(mode)) def ToShelf_CopySkin(path, *args): - MoveToShelf(path, Presets.runCopySkin, "CopySkin", "CopySkin") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.CopySkin), "CopySkin", "CopySkin") def ToShelf_WrapsCreate(path, *args): - MoveToShelf(path, Presets.runWrapsCreate, "WrapsCreate", "WrapsCreate") -# def ToShelf_WrapsConvert(path, *args): # TODO -# MoveToShelf(path, Presets.runWrapsConvert, "WrapsConvert", "WrapsConvert") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.WrapsCreate), "WrapsCreate", "WrapsCreate") +def ToShelf_WrapsConvert(path, *args): + MoveToShelf(path, ReadFunctionAsString(CodeSamples.WrapsConvert), "WrapsConvert", "WrapsConvert") # TODO add corresponding logic def ToShelf_BlendshapesReconstruct(path, *args): - MoveToShelf(path, Presets.runBlendshapesReconstruct, "BSReconstruct", "BSReconstruct") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BlendshapesReconstruct), "BSReconstruct", "BSReconstruct") def ToShelf_BlendshapesZeroWeights(path, *args): - MoveToShelf(path, Presets.runBlendshapesZeroWeights, "BSZeroWeights", "BSZeroWeights") - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.BlendshapesZeroWeights), "BSZeroWeights", "BSZeroWeights") # MOTION TRAIL def ToShelf_MotionTrailCreate(path, *args): - MoveToShelf(path, Presets.runMotionTrailCreate, "MotionTrailCreate", "MTCreate") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.MotionTrailCreate), "MotionTrailCreate", "MTCreate") def ToShelf_MotionTrailSelect(path, *args): - MoveToShelf(path, Presets.runMotionTrailSelect, "MotionTrailSelect", "MTSelect") + MoveToShelf(path, ReadFunctionAsString(CodeSamples.MotionTrailSelect), "MotionTrailSelect", "MTSelect") def ToShelf_MotionTrailDelete(path, *args): - MoveToShelf(path, Presets.runMotionTrailDelete, "MotionTrailDelete", "MTDelete") - + MoveToShelf(path, ReadFunctionAsString(CodeSamples.MotionTrailDelete), "MotionTrailDelete", "MTDelete") # RESET BUTTON def CreateResetButton(*args): # TODO get all published attributes diff --git a/GETOOLS_SOURCE/utils/Layers.py b/GETOOLS_SOURCE/utils/Layers.py index c45cdf1..182e6e2 100644 --- a/GETOOLS_SOURCE/utils/Layers.py +++ b/GETOOLS_SOURCE/utils/Layers.py @@ -26,11 +26,9 @@ from ..utils import Text - LayerBase = "BaseAnimation" LayerPrefix = "_layer_" - def Create(layerName, parent=LayerBase, *args): # if(cmds.objExists(layerName)): # cmds.warning("Layer \"{0}\" already exists".format(layerName)) diff --git a/GETOOLS_SOURCE/utils/Locators.py b/GETOOLS_SOURCE/utils/Locators.py index d163cb1..77b7edc 100644 --- a/GETOOLS_SOURCE/utils/Locators.py +++ b/GETOOLS_SOURCE/utils/Locators.py @@ -31,7 +31,6 @@ from ..utils import Parent from ..utils import Selector from ..utils import Text - from ..values import Enums nameBase = "gLoc" diff --git a/GETOOLS_SOURCE/utils/Other.py b/GETOOLS_SOURCE/utils/Other.py index 9d77dce..4e5e87d 100644 --- a/GETOOLS_SOURCE/utils/Other.py +++ b/GETOOLS_SOURCE/utils/Other.py @@ -26,6 +26,7 @@ # import maya.mel as mel from ..utils import Selector +from ..values import Enums def RotateOrderVisibility(on=True, *args): # Check selected objects @@ -34,7 +35,7 @@ def RotateOrderVisibility(on=True, *args): return for item in selectedList: - cmds.setAttr(item + ".rotateOrder", channelBox = on) + cmds.setAttr(item + "." + Enums.Attributes.rotateOrder, channelBox = on) def SegmentScaleCompensate(value=0, *args): # TODO refactor # Check selected objects @@ -42,9 +43,9 @@ def SegmentScaleCompensate(value=0, *args): # TODO refactor if (selectedList == None): return - selected = cmds.ls(selection = True, type = "joint") + selected = cmds.ls(selection = True, type = Enums.Types.joint) for item in selected: - cmds.setAttr(item + ".segmentScaleCompensate", value) + cmds.setAttr(item + "." + Enums.Attributes.segmentScaleCompensate, value) def JointDrawStyle(mode=0, *args): # TODO refactor # Check selected objects @@ -52,12 +53,12 @@ def JointDrawStyle(mode=0, *args): # TODO refactor if (selectedList == None): return - selected = cmds.ls(selection = True, type = "joint") + selected = cmds.ls(selection = True, type = Enums.Types.joint) for item in selected: - cmds.setAttr(item + ".drawStyle", mode) + cmds.setAttr(item + "." + Enums.Attributes.drawStyle, mode) def SelectJointsInScene(): # TODO make universal for other types - selected = cmds.ls(type = "joint") + selected = cmds.ls(type = Enums.Types.joint) cmds.select(selected) def GetShapeType(element, type): diff --git a/GETOOLS_SOURCE/utils/Selector.py b/GETOOLS_SOURCE/utils/Selector.py index 631549f..f0748b7 100644 --- a/GETOOLS_SOURCE/utils/Selector.py +++ b/GETOOLS_SOURCE/utils/Selector.py @@ -24,10 +24,12 @@ import maya.cmds as cmds +from ..values import Enums + def MultipleObjects(minimalCount=1, transformsOnly=True, shapes=False): # Save selected objects to variable if (transformsOnly): - selectedList = cmds.ls(selection = True, type = "transform", shapes = shapes) + selectedList = cmds.ls(selection = True, type = Enums.Types.transform, shapes = shapes) else: selectedList = cmds.ls(selection = True, shapes = shapes) @@ -51,7 +53,7 @@ def SelectHierarchyTransforms(*args): return None cmds.select(hierarchy = True) - list = cmds.ls(selection = True, type = "transform", shapes = False) + list = cmds.ls(selection = True, type = Enums.Types.transform, shapes = False) cmds.select(clear = True) for i in range(len(list)): diff --git a/GETOOLS_SOURCE/utils/Skinning.py b/GETOOLS_SOURCE/utils/Skinning.py index 7c9b2e6..73aad62 100644 --- a/GETOOLS_SOURCE/utils/Skinning.py +++ b/GETOOLS_SOURCE/utils/Skinning.py @@ -25,6 +25,7 @@ import maya.cmds as cmds from ..utils import Selector +from ..values import Enums def CopySkinWeightsFromLastMesh(*args): selected = Selector.MultipleObjects(2) @@ -46,7 +47,8 @@ def CopySkinWeightsFromLastMesh(*args): cmds.select(selected) def HasSkinCluster(targetObject): - skinClusterDestination = cmds.ls(cmds.listHistory(targetObject), type = "skinCluster") + history = cmds.listHistory(targetObject) + skinClusterDestination = cmds.ls(history, type = Enums.Types.skinCluster) if (len(skinClusterDestination) == 0): print("{0} doesn't have skinCluster".format(targetObject)) return False diff --git a/GETOOLS_SOURCE/utils/Toggles.py b/GETOOLS_SOURCE/utils/Toggles.py index f75437d..de16c01 100644 --- a/GETOOLS_SOURCE/utils/Toggles.py +++ b/GETOOLS_SOURCE/utils/Toggles.py @@ -26,7 +26,6 @@ from ..values import Enums - def Toggle(parameter): currentPanel = cmds.getPanel(withFocus = True) checkModelEditor = cmds.modelEditor(currentPanel, exists = True) @@ -39,7 +38,6 @@ def Toggle(parameter): cmds.modelEditor(currentPanel, edit = True, **{parameter: not check}) print("Panel \"{0}\", {1} {2}".format(currentPanel, parameter, not check)) - # def ToggleAllObjects(*args): Toggle(Enums.ModelEditor.allObjects) def ToggleCameras(*args): Toggle(Enums.ModelEditor.cameras) def ToggleControlVertices(*args): Toggle(Enums.ModelEditor.controlVertices) diff --git a/GETOOLS_SOURCE/values/CodeSamples.py b/GETOOLS_SOURCE/values/CodeSamples.py new file mode 100644 index 0000000..cffc751 --- /dev/null +++ b/GETOOLS_SOURCE/values/CodeSamples.py @@ -0,0 +1,329 @@ +# GETOOLS is under the terms of the MIT License + +# Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Logic in this module is not optimal enough, need manually change path names, methods and parameters. + +def GeneralWindow(): + import GETOOLS_SOURCE.modules.GeneralWindow as gtwindow + gtwindow.GeneralWindow().RUN_DOCKED() + + +# FILE +def SceneReload(): + import GETOOLS_SOURCE.utils.Scene as scene + scene.Reload() + +def ExitMaya(): + import GETOOLS_SOURCE.utils.Scene as scene + scene.ExitMaya() + + +# UTILS +def SelectHierarchy(): + import GETOOLS_SOURCE.utils.Selector as selector + selector.SelectHierarchy() + +def CreateResetButton(): + import GETOOLS_SOURCE.utils.Install as install + install.CreateResetButton() + + +# TOGGLES +def ToggleCameras(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleCameras() + +def ToggleControlVertices(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleControlVertices() + +def ToggleDeformers(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleDeformers() + +def ToggleDimensions(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleDimensions() + +def ToggleDynamicConstraints(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleDynamicConstraints() + +def ToggleDynamics(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleDynamics() + +def ToggleFluids(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleFluids() + +def ToggleFollicles(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleFollicles() + +def ToggleGrid(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleGrid() + +def ToggleHairSystems(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleHairSystems() + +def ToggleHandles(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleHandles() + +def ToggleHulls(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleHulls() + +def ToggleIkHandles(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleIkHandles() + +def ToggleJoints(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleJoints() + +def ToggleLights(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleLights() + +def ToggleLocators(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleLocators() + +def ToggleManipulators(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleManipulators() + +def ToggleNCloths(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleNCloths() + +def ToggleNParticles(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleNParticles() + +def ToggleNRigids(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleNRigids() + +def ToggleNurbsCurves(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleNurbsCurves() + +def ToggleNurbsSurfaces(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleNurbsSurfaces() + +def TogglePivots(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.TogglePivots() + +def TogglePlanes(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.TogglePlanes() + +def TogglePolymeshes(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.TogglePolymeshes() + +def ToggleShadows(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleShadows() + +def ToggleStrokes(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleStrokes() + +def ToggleSubdivSurfaces(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleSubdivSurfaces() + +def ToggleTextures(): + import GETOOLS_SOURCE.utils.Toggles as toggles + toggles.ToggleTextures() + + +# LOCATORS +def LocatorsSizeScale(): # brackets added method use + import GETOOLS_SOURCE.utils.Locators as locators + locators.SelectedLocatorsSizeScale + +def LocatorsSizeSet(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.SelectedLocatorsSizeSet() + +def LocatorCreate(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.Create() + +def LocatorsMatch(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = False) + +def LocatorsParent(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = True) + +def LocatorsPin(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = True) + +def LocatorsPinWithoutReverse(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = True, bake = True) + +def LocatorsPinPos(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = True, constrainRotate = False) + +def LocatorsPinRot(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelected(constraint = True, bake = True, constrainReverse = True, constrainTranslate = False, constrainRotate = True) + +def LocatorsRelative(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True, skipLastReverse = False) + +def LocatorsRelativeSkipLast(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateAndBakeAsChildrenFromLastSelected(constraintReverse = True) + +def LocatorsRelativeWithoutReverse(): + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateAndBakeAsChildrenFromLastSelected() + +def LocatorsAim(): # brackets added method use + import GETOOLS_SOURCE.utils.Locators as locators + locators.CreateOnSelectedAim + + +# BAKINNG +def BakeClassic(): # brackets added method use + import GETOOLS_SOURCE.utils.Baker as baker + baker.BakeSelected + +def BakeCustom(): # brackets added method use + import GETOOLS_SOURCE.utils.Baker as baker + baker.BakeSelected + +def BakeByLast(): # brackets added method use + import GETOOLS_SOURCE.utils.Baker as baker + baker.BakeSelectedByLastObject + +def BakeByWorld(): # brackets added method use + import GETOOLS_SOURCE.utils.Baker as baker + baker.BakeSelectedByWorld + + +# ANIMATION +def AnimOffset(): # brackets added method use + import GETOOLS_SOURCE.utils.Animation as animation + animation.OffsetObjects + +def DeleteKeys(): + import GETOOLS_SOURCE.utils.Animation as animation + animation.DeleteKeys(True) + +def DeleteNonkeyable(): + import GETOOLS_SOURCE.utils.Animation as animation + animation.DeleteKeysNonkeyable() + +def DeleteStatic(): + import GETOOLS_SOURCE.utils.Animation as animation + animation.DeleteStaticCurves() + +def EulerFilter(): + import GETOOLS_SOURCE.utils.Animation as animation + animation.FilterCurve() + +def SetInfinity(): # brackets added method use + import GETOOLS_SOURCE.utils.Animation as animation + animation.SetInfinity + +def SetTimeline(): # brackets added method use + import GETOOLS_SOURCE.utils.Timeline as timeline + timeline.SetTime + + +# RIGGING +def Constraint(): # brackets added method use + import GETOOLS_SOURCE.utils.Constraints as constraints + constraints.ConstrainSelectedToLastObject + +def DeleteConstraints(): + import GETOOLS_SOURCE.utils.Constraints as constraints + constraints.DeleteConstraintsOnSelected() + +def DisconnectTargets(): + import GETOOLS_SOURCE.utils.Constraints as constraints + constraints.DisconnectTargetsFromConstraintOnSelected() + +def RotateOrder(): # brackets added method use + import GETOOLS_SOURCE.utils.Other as other + other.RotateOrderVisibility + +def SegmentScaleCompensate(): # brackets added method use + import GETOOLS_SOURCE.utils.Other as other + other.SegmentScaleCompensate + +def JointDrawStyle(): # brackets added method use + import GETOOLS_SOURCE.utils.Other as other + other.JointDrawStyle + +def CopySkin(): + import GETOOLS_SOURCE.utils.Skinning as skinning + skinning.CopySkinWeightsFromLastMesh() + +def WrapsCreate(): + import GETOOLS_SOURCE.utils.Deformers as deformers + deformers.WrapsCreateOnSelected() + +def WrapsConvert(): # TODO + import GETOOLS_SOURCE.utils.Deformers as deformers + deformers.WrapsConvertFromSelected() + +def BlendshapesReconstruct(): + import GETOOLS_SOURCE.utils.Deformers as deformers + deformers.BlendshapesReconstruction() + +def BlendshapesZeroWeights(): + import GETOOLS_SOURCE.utils.Blendshapes as blendshapes + blendshapes.ZeroBlendshapeWeightsOnSelected() + + +# EXPERIMENTAL +def MotionTrailCreate(): + import GETOOLS_SOURCE.utils.MotionTrail as mtrail + mtrail.Create() + +def MotionTrailSelect(): + import GETOOLS_SOURCE.utils.MotionTrail as mtrail + mtrail.Select() + +def MotionTrailDelete(): + import GETOOLS_SOURCE.utils.MotionTrail as mtrail + mtrail.Delete() + diff --git a/GETOOLS_SOURCE/values/Enums.py b/GETOOLS_SOURCE/values/Enums.py index a9a202c..96812f7 100644 --- a/GETOOLS_SOURCE/values/Enums.py +++ b/GETOOLS_SOURCE/values/Enums.py @@ -47,7 +47,7 @@ class Attributes: visibility = "visibility" - scaleLocal = ("localScaleX", "localScaleY", "localScaleZ") + scaleLocal = ("localScaleX", "localScaleY", "localScaleZ") # used for locators rotateOrder = "rotateOrder" startFrame = "startFrame" From ff600a6dc5769588e026ccbfc58fd082864c0b0f Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 14:16:51 -0700 Subject: [PATCH 23/27] update drag and drop module, cleanup --- DRAG_AND_DROP_INSTALL.py | 26 ++++++++++++------------- GETOOLS_SOURCE/modules/CenterOfMass.py | 2 +- GETOOLS_SOURCE/modules/GeneralWindow.py | 6 +++--- GETOOLS_SOURCE/modules/Overlappy.py | 2 +- GETOOLS_SOURCE/modules/Rigging.py | 2 +- GETOOLS_SOURCE/modules/Settings.py | 2 +- GETOOLS_SOURCE/modules/Tools.py | 2 +- GETOOLS_SOURCE/utils/Animation.py | 2 +- GETOOLS_SOURCE/utils/Baker.py | 2 +- GETOOLS_SOURCE/utils/Blendshapes.py | 2 +- GETOOLS_SOURCE/utils/Colors.py | 2 +- GETOOLS_SOURCE/utils/Constraints.py | 2 +- GETOOLS_SOURCE/utils/Deformers.py | 2 +- GETOOLS_SOURCE/utils/Install.py | 17 +++++++--------- GETOOLS_SOURCE/utils/Layers.py | 2 +- GETOOLS_SOURCE/utils/Locators.py | 2 +- GETOOLS_SOURCE/utils/MayaSettings.py | 2 +- GETOOLS_SOURCE/utils/MotionTrail.py | 2 +- GETOOLS_SOURCE/utils/Other.py | 2 +- GETOOLS_SOURCE/utils/Parent.py | 2 +- GETOOLS_SOURCE/utils/Scene.py | 2 +- GETOOLS_SOURCE/utils/Selector.py | 2 +- GETOOLS_SOURCE/utils/Shelf.py | 2 +- GETOOLS_SOURCE/utils/Skinning.py | 2 +- GETOOLS_SOURCE/utils/Text.py | 2 +- GETOOLS_SOURCE/utils/Timeline.py | 2 +- GETOOLS_SOURCE/utils/Toggles.py | 2 +- GETOOLS_SOURCE/utils/UI.py | 2 +- GETOOLS_SOURCE/values/CodeSamples.py | 7 ++++--- GETOOLS_SOURCE/values/Enums.py | 2 +- GETOOLS_SOURCE/values/Icons.py | 2 +- GETOOLS_SOURCE/values/License.py | 2 +- changelog.txt | 12 ++++++++++++ 33 files changed, 67 insertions(+), 57 deletions(-) diff --git a/DRAG_AND_DROP_INSTALL.py b/DRAG_AND_DROP_INSTALL.py index a2bfeed..c58aaa8 100644 --- a/DRAG_AND_DROP_INSTALL.py +++ b/DRAG_AND_DROP_INSTALL.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,12 +20,13 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import os from GETOOLS_SOURCE.utils import Install from GETOOLS_SOURCE.utils import Shelf - +from GETOOLS_SOURCE.values import CodeSamples from GETOOLS_SOURCE.values import Icons from GETOOLS_SOURCE.values import License @@ -38,23 +38,23 @@ # Button settings buttonLabel = "GETools" -functionAddPathToEnvironment = Install.GetFunctionString(scriptPath) -buttonCommand = """\ -######################################### -{license} -### GETools -### https://github.com/GenEugene/GETools -######################################### +imports = """\ import os import sys import maya.cmds as cmds +""" + +environment = Install.GetFunctionString(scriptPath) +code = Install.ReadFunctionAsString(CodeSamples.GeneralWindow) -{func} -from GETOOLS_SOURCE.modules import GeneralWindow -GeneralWindow.GeneralWindow().RUN_DOCKED(\"{path}\")\ -""".format(func = functionAddPathToEnvironment, path = scriptPath, license = License.text) +# Generate code line by line +buttonCommand = "" +buttonCommand += License.text + "\n" +buttonCommand += imports + "\n" +buttonCommand += environment + "\n\n" +buttonCommand += code + "(\"{0}\")".format(scriptPath) # Drag and Drop function with button creation on current shelf diff --git a/GETOOLS_SOURCE/modules/CenterOfMass.py b/GETOOLS_SOURCE/modules/CenterOfMass.py index e217913..e207368 100644 --- a/GETOOLS_SOURCE/modules/CenterOfMass.py +++ b/GETOOLS_SOURCE/modules/CenterOfMass.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds from functools import partial diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 9efd72a..935492a 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds from functools import partial @@ -109,11 +109,11 @@ def PrintChannelBoxAttributes(*args): cmds.menuItem(divider = True) cmds.menuItem(label = "Print selected objects to console", command = Selector.PrintSelected, image = Icons.text) cmds.menuItem(label = "Print channel box selected attributes", command = PrintChannelBoxAttributes, image = Icons.text) - cmds.menuItem(divider = True) - cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) cmds.menuItem(dividerLabel = "Blendshapes", divider = True) cmds.menuItem(label = "Print Blendshapes Base Nodes", command = Blendshapes.GetBlendshapeNodesFromSelected, image = Icons.text) cmds.menuItem(label = "Print Blendshapes Names", command = Blendshapes.GetBlendshapeWeightsFromSelected, image = Icons.text) + cmds.menuItem(divider = True) + cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette, image = Icons.color) cmds.menu(label = "Toggle", tearOff = True) # cmds.menuItem(label = "All Objects", command = Toggles.ToggleAllObjects) diff --git a/GETOOLS_SOURCE/modules/Overlappy.py b/GETOOLS_SOURCE/modules/Overlappy.py index 6559584..3f71c59 100644 --- a/GETOOLS_SOURCE/modules/Overlappy.py +++ b/GETOOLS_SOURCE/modules/Overlappy.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds import maya.mel as mel diff --git a/GETOOLS_SOURCE/modules/Rigging.py b/GETOOLS_SOURCE/modules/Rigging.py index 3d28e5a..a70cc80 100644 --- a/GETOOLS_SOURCE/modules/Rigging.py +++ b/GETOOLS_SOURCE/modules/Rigging.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds from functools import partial diff --git a/GETOOLS_SOURCE/modules/Settings.py b/GETOOLS_SOURCE/modules/Settings.py index 4743940..2ca0486 100644 --- a/GETOOLS_SOURCE/modules/Settings.py +++ b/GETOOLS_SOURCE/modules/Settings.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene from ..utils import Colors diff --git a/GETOOLS_SOURCE/modules/Tools.py b/GETOOLS_SOURCE/modules/Tools.py index a90ef61..f0ca8e2 100644 --- a/GETOOLS_SOURCE/modules/Tools.py +++ b/GETOOLS_SOURCE/modules/Tools.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds from functools import partial diff --git a/GETOOLS_SOURCE/utils/Animation.py b/GETOOLS_SOURCE/utils/Animation.py index c552c98..0533ad8 100644 --- a/GETOOLS_SOURCE/utils/Animation.py +++ b/GETOOLS_SOURCE/utils/Animation.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds import maya.mel as mel diff --git a/GETOOLS_SOURCE/utils/Baker.py b/GETOOLS_SOURCE/utils/Baker.py index 2a621fd..38b20ad 100644 --- a/GETOOLS_SOURCE/utils/Baker.py +++ b/GETOOLS_SOURCE/utils/Baker.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Blendshapes.py b/GETOOLS_SOURCE/utils/Blendshapes.py index 2efe31a..4c29853 100644 --- a/GETOOLS_SOURCE/utils/Blendshapes.py +++ b/GETOOLS_SOURCE/utils/Blendshapes.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds # import maya.mel as mel diff --git a/GETOOLS_SOURCE/utils/Colors.py b/GETOOLS_SOURCE/utils/Colors.py index 0f96a3d..0beb347 100644 --- a/GETOOLS_SOURCE/utils/Colors.py +++ b/GETOOLS_SOURCE/utils/Colors.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene blackWhite00 = (0, 0, 0) blackWhite10 = (0.1, 0.1, 0.1) diff --git a/GETOOLS_SOURCE/utils/Constraints.py b/GETOOLS_SOURCE/utils/Constraints.py index 674e387..0d963da 100644 --- a/GETOOLS_SOURCE/utils/Constraints.py +++ b/GETOOLS_SOURCE/utils/Constraints.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Deformers.py b/GETOOLS_SOURCE/utils/Deformers.py index 05d2644..8a90e04 100644 --- a/GETOOLS_SOURCE/utils/Deformers.py +++ b/GETOOLS_SOURCE/utils/Deformers.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds # import maya.mel as mel diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index b926bdb..b0155c6 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,7 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene -# Logic in this module is not optimal enough, need manually change path names, methods and parameters. +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import os import sys @@ -63,14 +62,12 @@ def GetFunctionString(path, *args): sys.path.insert(0, "{path}")\ """.format(path = path) def GetFunctionStringForTool(path, tool, *args): - return """\ -import os -import sys - -{path} - -{tool}\ -""".format(path = GetFunctionString(path), tool = tool) + result = "" + result += "import os" + "\n" + result += "import sys" + "\n\n" + result += GetFunctionString(path) + "\n\n" + result += tool + return result def MoveToShelf(path, tool, label, labelImage, *args): command = GetFunctionStringForTool(path, tool) Shelf.AddToCurrentShelf( diff --git a/GETOOLS_SOURCE/utils/Layers.py b/GETOOLS_SOURCE/utils/Layers.py index 182e6e2..1ab1aa5 100644 --- a/GETOOLS_SOURCE/utils/Layers.py +++ b/GETOOLS_SOURCE/utils/Layers.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Locators.py b/GETOOLS_SOURCE/utils/Locators.py index 77b7edc..3a2d1dc 100644 --- a/GETOOLS_SOURCE/utils/Locators.py +++ b/GETOOLS_SOURCE/utils/Locators.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/MayaSettings.py b/GETOOLS_SOURCE/utils/MayaSettings.py index fd82e64..b045f79 100644 --- a/GETOOLS_SOURCE/utils/MayaSettings.py +++ b/GETOOLS_SOURCE/utils/MayaSettings.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/MotionTrail.py b/GETOOLS_SOURCE/utils/MotionTrail.py index 3a0d792..3e74c49 100644 --- a/GETOOLS_SOURCE/utils/MotionTrail.py +++ b/GETOOLS_SOURCE/utils/MotionTrail.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Other.py b/GETOOLS_SOURCE/utils/Other.py index 4e5e87d..7df264d 100644 --- a/GETOOLS_SOURCE/utils/Other.py +++ b/GETOOLS_SOURCE/utils/Other.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds # import maya.mel as mel diff --git a/GETOOLS_SOURCE/utils/Parent.py b/GETOOLS_SOURCE/utils/Parent.py index b897121..080decf 100644 --- a/GETOOLS_SOURCE/utils/Parent.py +++ b/GETOOLS_SOURCE/utils/Parent.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Scene.py b/GETOOLS_SOURCE/utils/Scene.py index 4f9b76f..b965e78 100644 --- a/GETOOLS_SOURCE/utils/Scene.py +++ b/GETOOLS_SOURCE/utils/Scene.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Selector.py b/GETOOLS_SOURCE/utils/Selector.py index f0748b7..6dff6ac 100644 --- a/GETOOLS_SOURCE/utils/Selector.py +++ b/GETOOLS_SOURCE/utils/Selector.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Shelf.py b/GETOOLS_SOURCE/utils/Shelf.py index af3b5db..8ed71ad 100644 --- a/GETOOLS_SOURCE/utils/Shelf.py +++ b/GETOOLS_SOURCE/utils/Shelf.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Skinning.py b/GETOOLS_SOURCE/utils/Skinning.py index 73aad62..87000e9 100644 --- a/GETOOLS_SOURCE/utils/Skinning.py +++ b/GETOOLS_SOURCE/utils/Skinning.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Text.py b/GETOOLS_SOURCE/utils/Text.py index 7e6fed2..773a45f 100644 --- a/GETOOLS_SOURCE/utils/Text.py +++ b/GETOOLS_SOURCE/utils/Text.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/Timeline.py b/GETOOLS_SOURCE/utils/Timeline.py index b89e1e6..d6b9530 100644 --- a/GETOOLS_SOURCE/utils/Timeline.py +++ b/GETOOLS_SOURCE/utils/Timeline.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds import maya.mel as mel diff --git a/GETOOLS_SOURCE/utils/Toggles.py b/GETOOLS_SOURCE/utils/Toggles.py index de16c01..3cf5f5a 100644 --- a/GETOOLS_SOURCE/utils/Toggles.py +++ b/GETOOLS_SOURCE/utils/Toggles.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/utils/UI.py b/GETOOLS_SOURCE/utils/UI.py index 60046b6..2c38a45 100644 --- a/GETOOLS_SOURCE/utils/UI.py +++ b/GETOOLS_SOURCE/utils/UI.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene import maya.cmds as cmds diff --git a/GETOOLS_SOURCE/values/CodeSamples.py b/GETOOLS_SOURCE/values/CodeSamples.py index cffc751..e654f9b 100644 --- a/GETOOLS_SOURCE/values/CodeSamples.py +++ b/GETOOLS_SOURCE/values/CodeSamples.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,11 +20,13 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene # Logic in this module is not optimal enough, need manually change path names, methods and parameters. -def GeneralWindow(): + +def GeneralWindow(): # brackets added method use import GETOOLS_SOURCE.modules.GeneralWindow as gtwindow - gtwindow.GeneralWindow().RUN_DOCKED() + gtwindow.GeneralWindow().RUN_DOCKED # FILE diff --git a/GETOOLS_SOURCE/values/Enums.py b/GETOOLS_SOURCE/values/Enums.py index 96812f7..ac1deef 100644 --- a/GETOOLS_SOURCE/values/Enums.py +++ b/GETOOLS_SOURCE/values/Enums.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene class Types: transform = "transform" diff --git a/GETOOLS_SOURCE/values/Icons.py b/GETOOLS_SOURCE/values/Icons.py index a6f7f6d..a941e52 100644 --- a/GETOOLS_SOURCE/values/Icons.py +++ b/GETOOLS_SOURCE/values/Icons.py @@ -1,5 +1,4 @@ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,6 +20,7 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene root = "\\GETOOLS_SOURCE" diff --git a/GETOOLS_SOURCE/values/License.py b/GETOOLS_SOURCE/values/License.py index 3eba71e..de24752 100644 --- a/GETOOLS_SOURCE/values/License.py +++ b/GETOOLS_SOURCE/values/License.py @@ -1,6 +1,5 @@ text = """\ # GETOOLS is under the terms of the MIT License - # Copyright (c) 2018-2024 Eugene Gataulin (GenEugene). All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,5 +21,6 @@ # SOFTWARE. # Author: Eugene Gataulin tek942@gmail.com https://www.linkedin.com/in/geneugene +# Source code: https://github.com/GenEugene/GETools or https://app.gumroad.com/geneugene """ diff --git a/changelog.txt b/changelog.txt index 1e0ee9b..e59557a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,17 @@ GETools changelog +v1.0.5 +- [UI] Rework Drag and Drop install logic, less hardcode. +- [UI] Rework Install module, remove hardcode. +- [UI] Activate tear-off on drop downs. +- [UTILS] Added printing blendshapes on selected. +- [TOGGLE] Added toggle buttons for active viewport. +- [RIGGING] Added wraps creation button. +- [RIGGING] Added blendshapes projecting button. +- [RIGGING] Added blendshapes zeroing button. +- Added some prototypes. +- Improved various modules and overall quality. + v1.0.4 - [OVERLAPPY] Reworked Nucleus implementation with non-destructive way. - [UTILS] Added simple SelectHierarchy method. From 268d8463bdc24b708f06326a2b0dae0ce14c4314 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 16:53:36 -0700 Subject: [PATCH 24/27] Update changelog.txt --- changelog.txt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index e59557a..ab29169 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,16 +1,13 @@ GETools changelog v1.0.5 -- [UI] Rework Drag and Drop install logic, less hardcode. -- [UI] Rework Install module, remove hardcode. -- [UI] Activate tear-off on drop downs. +- Decreased hardcode in Drag and Drop logic. +- Reworked Button Install module. +- Added toggle buttons for active viewport. +- [RIGGING] Added wraps button. +- [RIGGING] Added blendshapes reconstruct button. +- [RIGGING] Added blendshapes zero weights button. - [UTILS] Added printing blendshapes on selected. -- [TOGGLE] Added toggle buttons for active viewport. -- [RIGGING] Added wraps creation button. -- [RIGGING] Added blendshapes projecting button. -- [RIGGING] Added blendshapes zeroing button. -- Added some prototypes. -- Improved various modules and overall quality. v1.0.4 - [OVERLAPPY] Reworked Nucleus implementation with non-destructive way. From 494c6f1de07f00d85f6e4f5d7de33a2504eccbe4 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 16:57:51 -0700 Subject: [PATCH 25/27] save --- GETOOLS_SOURCE/modules/GeneralWindow.py | 4 ++-- GETOOLS_SOURCE/modules/Tools.py | 8 ++++---- GETOOLS_SOURCE/utils/Install.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 935492a..18cbf06 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -374,8 +374,8 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Max In", command = partial(Install.ToShelf_SetTimelineMaxIn, self.directory)) cmds.menuItem(label = "Max Out", command = partial(Install.ToShelf_SetTimelineMaxOut, self.directory)) cmds.menuItem(divider = True) - cmds.menuItem(label = "Expand Out", command = partial(Install.ToShelf_SetTimelineExpandOut, self.directory)) - cmds.menuItem(label = "Expand In", command = partial(Install.ToShelf_SetTimelineExpandIn, self.directory)) + cmds.menuItem(label = "Expand Out", command = partial(Install.ToShelf_SetTimelineFocusOut, self.directory)) + cmds.menuItem(label = "Expand In", command = partial(Install.ToShelf_SetTimelineFocusIn, self.directory)) cmds.menuItem(divider = True) cmds.menuItem(label = "Selected Range", command = partial(Install.ToShelf_SetTimelineSet, self.directory)) cmds.setParent('..', menu = True) diff --git a/GETOOLS_SOURCE/modules/Tools.py b/GETOOLS_SOURCE/modules/Tools.py index f0ca8e2..10b920e 100644 --- a/GETOOLS_SOURCE/modules/Tools.py +++ b/GETOOLS_SOURCE/modules/Tools.py @@ -96,8 +96,8 @@ class ToolsAnnotations: timelineSetMinIn = "Set minimal inner timeline value" timelineSetMaxIn = "Set maximum inner timeline value" timelineSetMaxOut = "Set maximum outer timeline value" - timelineExpandOut = "Expand timeline range to outer range" - timelineExpandIn = "Expand timeline range to inner range" + timelineFocusOut = "Focus outer timeline range" + timelineFocusIn = "Focus inner timeline range" timelineSetRange = "Set timeline inner range on selected range by mouse" animationOffset = "Move animation on selected objects in time.\nThe animation will move relative to the index of the selected object.\nThe best way to desync animation.\nWorks with selection in the channel box." @@ -300,8 +300,8 @@ def UILayoutTimeline(self, layoutMain, windowWidthMargin, lineHeight): cmds.button(label = "<-", command = partial(Timeline.SetTime, 1), backgroundColor = Colors.green50, annotation = ToolsAnnotations.timelineSetMinIn) cmds.button(label = "->", command = partial(Timeline.SetTime, 2), backgroundColor = Colors.green50, annotation = ToolsAnnotations.timelineSetMaxIn) cmds.button(label = ">>", command = partial(Timeline.SetTime, 4), backgroundColor = Colors.green10, annotation = ToolsAnnotations.timelineSetMaxOut) - cmds.button(label = "<->", command = partial(Timeline.SetTime, 5), backgroundColor = Colors.orange10, annotation = ToolsAnnotations.timelineExpandOut) - cmds.button(label = ">-<", command = partial(Timeline.SetTime, 6), backgroundColor = Colors.orange10, annotation = ToolsAnnotations.timelineExpandIn) + cmds.button(label = "<->", command = partial(Timeline.SetTime, 5), backgroundColor = Colors.orange10, annotation = ToolsAnnotations.timelineFocusOut) + cmds.button(label = ">-<", command = partial(Timeline.SetTime, 6), backgroundColor = Colors.orange10, annotation = ToolsAnnotations.timelineFocusIn) cmds.button(label = "|<->|", command = partial(Timeline.SetTime, 7), backgroundColor = Colors.orange50, annotation = ToolsAnnotations.timelineSetRange) diff --git a/GETOOLS_SOURCE/utils/Install.py b/GETOOLS_SOURCE/utils/Install.py index b0155c6..a6d7b1b 100644 --- a/GETOOLS_SOURCE/utils/Install.py +++ b/GETOOLS_SOURCE/utils/Install.py @@ -219,10 +219,10 @@ def ToShelf_SetTimelineMaxIn(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(2)", "SetTimelineMaxIn", "->") def ToShelf_SetTimelineMaxOut(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(4)", "SetTimelineMaxOut", ">>") -def ToShelf_SetTimelineExpandOut(path, *args): - MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(5)", "SetTimelineExpandOut", "<->") -def ToShelf_SetTimelineExpandIn(path, *args): - MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(6)", "SetTimelineExpandIn", ">-<") +def ToShelf_SetTimelineFocusOut(path, *args): + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(5)", "SetTimelineFocusOut", "<->") +def ToShelf_SetTimelineFocusIn(path, *args): + MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(6)", "SetTimelineFocusIn", ">-<") def ToShelf_SetTimelineSet(path, *args): MoveToShelf(path, ReadFunctionAsString(CodeSamples.SetTimeline) + "(7)", "SetTimelineSet", "|<->|") From abd6b95fcddde0e70e06d48ab52f5ac77cc667d8 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 16:58:52 -0700 Subject: [PATCH 26/27] Update GeneralWindow.py --- GETOOLS_SOURCE/modules/GeneralWindow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GETOOLS_SOURCE/modules/GeneralWindow.py b/GETOOLS_SOURCE/modules/GeneralWindow.py index 18cbf06..bb0f5d3 100644 --- a/GETOOLS_SOURCE/modules/GeneralWindow.py +++ b/GETOOLS_SOURCE/modules/GeneralWindow.py @@ -374,8 +374,8 @@ def LayoutMenuInstall(self): cmds.menuItem(label = "Max In", command = partial(Install.ToShelf_SetTimelineMaxIn, self.directory)) cmds.menuItem(label = "Max Out", command = partial(Install.ToShelf_SetTimelineMaxOut, self.directory)) cmds.menuItem(divider = True) - cmds.menuItem(label = "Expand Out", command = partial(Install.ToShelf_SetTimelineFocusOut, self.directory)) - cmds.menuItem(label = "Expand In", command = partial(Install.ToShelf_SetTimelineFocusIn, self.directory)) + cmds.menuItem(label = "Focus Out", command = partial(Install.ToShelf_SetTimelineFocusOut, self.directory)) + cmds.menuItem(label = "Focus In", command = partial(Install.ToShelf_SetTimelineFocusIn, self.directory)) cmds.menuItem(divider = True) cmds.menuItem(label = "Selected Range", command = partial(Install.ToShelf_SetTimelineSet, self.directory)) cmds.setParent('..', menu = True) From b140d1de41ed218f623039bae2359f9145afea3c Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 9 Jul 2024 20:30:31 -0700 Subject: [PATCH 27/27] Update changelog.txt --- changelog.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index ab29169..f80c913 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,13 +1,16 @@ GETools changelog v1.0.5 +- Fixed motion trails to shelf button - Decreased hardcode in Drag and Drop logic. - Reworked Button Install module. -- Added toggle buttons for active viewport. +- [UI] Added tear-off to sub menus +- [UTILS] Added toggle buttons for active viewport. +- [UTILS] Added "Print Blendshapes Base Nodes". +- [UTILS] Added "Print Blendshapes Names". - [RIGGING] Added wraps button. - [RIGGING] Added blendshapes reconstruct button. -- [RIGGING] Added blendshapes zero weights button. -- [UTILS] Added printing blendshapes on selected. +- [RIGGING] Added "Zero Blendshapes Weights" button. v1.0.4 - [OVERLAPPY] Reworked Nucleus implementation with non-destructive way.