Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.2.5 #89

Merged
merged 17 commits into from
Aug 6, 2024
9 changes: 3 additions & 6 deletions DRAG_AND_DROP_INSTALL.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
scriptPath = scriptPath.replace("\\", "/")
Install.AddPathToEnvironment(scriptPath)

# Button settings
buttonLabel = "GETools"

imports = """\
import os
import sys
Expand All @@ -59,9 +56,9 @@
def onMayaDroppedPythonFile(*args, **kwargs):
Shelf.AddToCurrentShelf(
command = buttonCommand,
label = buttonLabel,
label = Settings.buttonLabel,
annotation = "GenEugene Animation Tools",
imagePath = scriptPath + (Icons.get1_face if Settings.useFaceIcon else Icons.get1),
imageHighlightPath= scriptPath + (Icons.get2_face if Settings.useFaceIcon else Icons.get2),
image = scriptPath + Icons.get1[0],
imageHighlight = scriptPath + Icons.get2[0],
)

4 changes: 2 additions & 2 deletions GETOOLS_SOURCE/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .utils import Colors


useFaceIcon = False
buttonLabel = "GETools"

windowName = "windowGETools"
dockName = "dockGETools"
Expand All @@ -43,7 +43,7 @@
windowWidthScroll = windowWidth - windowWidthScrollSpace
windowWidthMargin = windowWidthScroll - margin * 2

frames1Color = Colors.blackWhite00
frames1Color = Colors.blackWhite13
frames2Color = Colors.blackWhite20
frames2Prefix = "// "

27 changes: 27 additions & 0 deletions GETOOLS_SOURCE/_prototypes/Dialogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import maya.cmds as cmds

cmds.confirmDialog(
title = "Zero offset detected",
message = "For ROTATION BAKING need to use particle offset with non zero values.\nIf offset is zero the particle will remain on the same position as original object, so no rotation will be generated.\n",
messageAlign = "left",
icon = "warning",

button = ["Continue anyway","Cancel"],
annotation = ["bla", "qwe"],

defaultButton = "Cancel",
cancelButton = "Cancel",

dismissString = "Dismissed"
)


# Maya 2022+
cmds.framelessDialog(
title = "Zero offset detected",
message = "For ROTATION BAKING need to use particle offset with non zero values.\nIf offset is zero the particle will remain on the same position as original object, so no rotation will be generated.\n",
path = "OVERLAPPY\Particle Offset\MoveX-Y-Z",
button = ["Bake with zero offset", "Cancel"],
primary = ["OK"]
)

8 changes: 4 additions & 4 deletions GETOOLS_SOURCE/_prototypes/Namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ def ClearRigNamespaces(_namespace=''):
cmds.select("SET_EXPORT_ANIM_ALL", r = 1) # Select all objects for baking

def NamespacesFromSelected(self, *args):
selected = cmds.ls(sl = 1)
if(selected):
selected = cmds.ls(selection = True)
if (selected):
namespaces = list("")
for i in range(len(selected)):
namespace = selected[i].split(':')[0]

# Empty namespace
count = selected[i].split(':')
if(len(count) < 2):
if (len(count) < 2):
namespace = ""

for i in range(len(selected)):
if(namespace not in namespaces):
if (namespace not in namespaces):
namespaces.append(namespace)

return selected, namespaces
Expand Down
2 changes: 1 addition & 1 deletion GETOOLS_SOURCE/_prototypes/SetAttributesBySimpleName.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def FindAllObjects(objName):
objects = cmds.ls(type = "transform", long = True)
result = []
for item in objects:
if(item.endswith("|" + objName) or item.endswith(":" + objName)):
if (item.endswith("|" + objName) or item.endswith(":" + objName)):
result.append(item)
return result

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if(`isChannelBoxRaised`)
if (`isChannelBoxRaised`)
{
openAEWindow;
}
else if(`isAttributeEditorRaised`)
else if (`isAttributeEditorRaised`)
{
raiseChannelBox;
}
16 changes: 8 additions & 8 deletions GETOOLS_SOURCE/_prototypes/ToggleValues.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
cmds.select("test1:cube1", replace = True)

# Extract namespace from selected
selected = cmds.ls(sl = True)[0]
selected = cmds.ls(selection = True)[0]
resultNamespace = selected.split(':')[0]
count = selected.split(':')

if(len(count) < 2):
if (len(count) < 2):
resultNamespace = None

attributePath = selected + ".translateY"

currentValue = cmds.getAttr(attributePath)
resultValue = None

if(currentValue < toggleValue[0]):
if (currentValue < toggleValue[0]):
resultValue = toggleValue[0]

elif(currentValue > toggleValue[1]):
elif (currentValue > toggleValue[1]):
resultValue = toggleValue[1]

elif(currentValue > toggleValue[0] and currentValue < toggleValue[1]):
elif (currentValue > toggleValue[0] and currentValue < toggleValue[1]):
mathResult = currentValue - (toggleValue[1] - toggleValue[0]) / 2
if(mathResult <= 0):
if (mathResult <= 0):
resultValue = toggleValue[0]
else:
resultValue = toggleValue[1]

elif(currentValue == toggleValue[0]):
elif (currentValue == toggleValue[0]):
resultValue = toggleValue[1]

elif(currentValue == toggleValue[1]):
elif (currentValue == toggleValue[1]):
resultValue = toggleValue[0]

cmds.setAttr(attributePath, resultValue)
Expand Down
11 changes: 8 additions & 3 deletions GETOOLS_SOURCE/modules/CenterOfMass.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ class CenterOfMass:
name = "CENTER OF MASS"
title = name + " " + version

def __init__(self):
# HACK use only for code editor # TODO try to find better way to get access to other classes with cross import
# from ..modules import GeneralWindow
# def __init__(self, generalInstance: GeneralWindow.GeneralWindow):
def __init__(self, generalInstance):
self.generalInstance = generalInstance

self.COMObject = None
self.CachedSelectedObjects = None

Expand Down Expand Up @@ -283,7 +288,7 @@ def BakeScenario2(self, *args):
cmds.select(clear = True)
return

self.CachedSelectedObjects = Locators.CreateAndBakeAsChildrenFromLastSelected()
self.CachedSelectedObjects = Locators.CreateAndBakeAsChildrenFromLastSelected(euler = self.generalInstance.menuCheckboxEulerFilter.Get())
return self.CachedSelectedObjects
def BakeScenario3(self, *args):
objects = self.BakeScenario2()
Expand All @@ -299,7 +304,7 @@ def BakeCached(self, *args):
return

cmds.select(self.CachedSelectedObjects[0][0:-1])
Baker.BakeSelected()
Baker.BakeSelected(euler = self.generalInstance.menuCheckboxEulerFilter.Get())
cmds.delete(self.CachedSelectedObjects[1][-1])

def LinkCached(self, maintainOffset=False, *args):
Expand Down
43 changes: 29 additions & 14 deletions GETOOLS_SOURCE/modules/GeneralWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ..modules import Overlappy
from ..modules import Rigging
from ..modules import Tools
from ..utils import Annotation
from ..utils import Blendshapes
from ..utils import Colors
from ..utils import Install
Expand All @@ -37,23 +38,28 @@
from ..utils import MotionTrail
from ..utils import Scene
from ..utils import Selector
from ..utils import Shelf
from ..utils import Skinning
from ..utils import Toggles
from ..utils import UI
from ..values import Icons


class GeneralWindow:
version = "v1.1.0"
version = "v1.2.5"
name = "GETools"
title = name + " " + version

def __init__(self):
self.directory = ""

self.frameTools = None
self.frameRigging = None
self.frameOverlappy = None
self.frameCenterOfMass = None
self.frameExperimental = None

self.menuCheckboxEulerFilter = None
def CreateUI(self):
if cmds.window(Settings.windowName, exists = True):
cmds.deleteUI(Settings.windowName)
Expand Down Expand Up @@ -107,6 +113,8 @@ def PrintChannelBoxAttributes(*args):
cmds.menuItem(label = "Select Skinned Meshes Or Joints", command = Skinning.SelectSkinnedMeshesOrJoints)
# cmds.menuItem(label = "Create Reset Button", command = Install.CreateResetButton)
cmds.menuItem(divider = True)
cmds.menuItem(label = "Annotate selected", command = Annotation.AnnotateSelected)
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(dividerLabel = "Blendshapes", divider = True)
Expand Down Expand Up @@ -147,8 +155,7 @@ def PrintChannelBoxAttributes(*args):
cmds.menuItem(label = "Subdiv Surfaces", command = Toggles.ToggleSubdivSurfaces)
cmds.menuItem(label = "Textures", command = Toggles.ToggleTextures, image = Icons.image)


self.LayoutMenuInstall()
self.LayoutMenuOptions()

cmds.menu(label = "Help", tearOff = True) # , helpMenu = True
def LinkVersionHistory(self): cmds.showHelp("https://github.com/GenEugene/GETools/blob/master/changelog.txt", absolute = True)
Expand All @@ -162,7 +169,7 @@ def LinkDiscord(self): cmds.showHelp("https://discord.gg/heMxJhTqCz", absolute =
def LinkShareIdeas(self): cmds.showHelp("https://github.com/GenEugene/GETools/discussions/categories/ideas", absolute = True)
def LinkReport(self): cmds.showHelp("https://github.com/GenEugene/GETools/discussions/categories/report-a-problem", absolute = True)

cmds.menuItem(label = "About GETools", enable = False, image = self.directory + Icons.get1) # TODO add window with information
cmds.menuItem(label = "About GETools", enable = False, image = self.directory + Icons.get1[0]) # TODO add window with information
cmds.menuItem(label = "Version History", command = LinkVersionHistory)
cmds.menuItem(dividerLabel = "Links", divider = True)
cmds.menuItem(label = "GitHub", command = LinkGithub, image = Icons.home)
Expand All @@ -177,7 +184,9 @@ def LinkReport(self): cmds.showHelp("https://github.com/GenEugene/GETools/discus
cmds.menuItem(dividerLabel = "Support", divider = True)
cmds.menuItem(label = "Share your Ideas", command = LinkShareIdeas, image = Icons.light)
cmds.menuItem(label = "Report a Problem", command = LinkReport, image = Icons.warning)

cmds.menuItem(divider = True)
cmds.menuItem(label = "Change Icon", command = partial(Shelf.ToggleButtonIcons, self.directory))

# DEV ZONE
def LayerCreate(*args):
Layers.Create("testLayer")
Expand Down Expand Up @@ -206,9 +215,15 @@ def LayerMove(*args):
# cmds.menuItem(label = "Layer Get Selected", command = LayerGetSelected)
# cmds.menuItem(label = "Layer Move", command = LayerMove)
pass
def LayoutMenuInstall(self):
cmds.menu(label = "To Shelf", tearOff = True)

def LayoutMenuOptions(self):
cmds.menu(label = "Options", tearOff = True)

self.menuCheckboxEulerFilter = UI.MenuCheckbox(label = "Euler Filter After Baking", value = False, valueDefault = False)

cmds.menuItem(dividerLabel = "Install", divider = True)

# Install
cmds.menuItem(subMenu = True, label = "Install Buttons To Current Shelf", tearOff = True, image = Icons.fileOpen)
cmds.menuItem(subMenu = True, label = "File", tearOff = True, image = Icons.fileOpen)
cmds.menuItem(label = "Reload Scene (force)", command = partial(Install.ToShelf_ReloadScene, self.directory), image = Icons.reset)
cmds.menuItem(label = "Exit Maya (force)", command = partial(Install.ToShelf_ExitMaya, self.directory), image = Icons.off)
Expand Down Expand Up @@ -344,7 +359,7 @@ def LayoutMenuInstall(self):
cmds.menuItem(label = "Static", command = partial(Install.ToShelf_DeleteStatic, self.directory))
cmds.setParent('..', menu = True)
#
cmds.menuItem(label = "Euler Filter", command = partial(Install.ToShelf_EulerFilter, self.directory), image = Icons.filterActive)
cmds.menuItem(label = "Euler Filter", command = partial(Install.ToShelf_EulerFilterOnSelected, self.directory), image = Icons.filterActive)
#
cmds.menuItem(subMenu = True, label = "Infinity", tearOff = True, image = Icons.infinity)
cmds.menuItem(label = "Constant", command = partial(Install.ToShelf_SetInfinity, self.directory, 1))
Expand Down Expand Up @@ -427,7 +442,7 @@ def LayoutMenuInstall(self):
cmds.menuItem(label = "Reconstruct", command = partial(Install.ToShelf_BlendshapesReconstruct, self.directory), image = Icons.blendshape)
cmds.menuItem(label = "Extract Shapes", command = partial(Install.ToShelf_BlendshapesExtractShapes, self.directory), image = Icons.polyMesh)
cmds.menuItem(label = "Zero Weights", command = partial(Install.ToShelf_BlendshapesZeroWeights, self.directory), image = Icons.zero)
cmds.setParent('..', menu = True)
# cmds.setParent('..', menu = True)

cmds.menuItem(dividerLabel = "EXPERIMENTAL", divider = True)
###
Expand All @@ -441,21 +456,21 @@ def LayoutMenuInstall(self):
def LayoutTitle(self, parentLayout): # TODO figure out how to use resizeable images
cmds.columnLayout("layoutTitle", parent = parentLayout, adjustableColumn = False)
size = 30
cmds.iconTextButton(label = "GETOOLS", style = "iconAndTextHorizontal", image = self.directory + Icons.get1, width = size, height = size)
cmds.iconTextButton(label = "GETOOLS", style = "iconAndTextHorizontal", image = self.directory + Icons.get1[0], width = size, height = size)
# cmds.image(image = self.directory + Icons.get, width = size, height = size)

def LayoutTools(self, parentLayout):
self.frameTools = cmds.frameLayout("layoutTools", parent = parentLayout, label = "1. " + Tools.Tools.title, collapsable = True, backgroundColor = Settings.frames1Color, marginWidth = Settings.margin, marginHeight = Settings.margin)
Tools.Tools().UICreate(self.frameTools)
Tools.Tools(self).UICreate(self.frameTools)
def LayoutRigging(self, parentLayout):
self.frameRigging = cmds.frameLayout("layoutRigging", parent = parentLayout, label = "2. " + Rigging.Rigging.title, collapsable = True, backgroundColor = Settings.frames1Color, marginWidth = Settings.margin, marginHeight = Settings.margin)
Rigging.Rigging().UICreate(self.frameRigging)
def LayoutOverlappy(self, parentLayout):
self.frameOverlappy = cmds.frameLayout("layoutOverlappy", parent = parentLayout, label = "3. " + Overlappy.Overlappy.title, collapsable = True, backgroundColor = Settings.frames1Color, marginWidth = Settings.margin, marginHeight = Settings.margin)
Overlappy.Overlappy().UICreate(self.frameOverlappy)
Overlappy.Overlappy(self).UICreate(self.frameOverlappy)
def LayoutCenterOfMass(self, parentLayout):
self.frameCenterOfMass = cmds.frameLayout("layoutCenterOfMass", parent = parentLayout, label = "4. " + CenterOfMass.CenterOfMass.title, collapsable = True, backgroundColor = Settings.frames1Color, marginWidth = Settings.margin, marginHeight = Settings.margin)
CenterOfMass.CenterOfMass().UICreate(self.frameCenterOfMass)
CenterOfMass.CenterOfMass(self).UICreate(self.frameCenterOfMass)
def LayoutExperimental(self, parentLayout):
self.frameExperimental = cmds.frameLayout("layoutExperimental", parent = parentLayout, label = "5. " + "EXPERIMENTAL", collapsable = True, backgroundColor = Settings.frames1Color, marginWidth = Settings.margin, marginHeight = Settings.margin)
cmds.popupMenu()
Expand Down
Loading