Skip to content

Commit

Permalink
Merge pull request #61 from GenEugene/develop
Browse files Browse the repository at this point in the history
Complete version 0.0.12
  • Loading branch information
GenEugene committed Dec 16, 2023
2 parents bd746f3 + 3d49ad1 commit 32c2d29
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 198 deletions.
84 changes: 38 additions & 46 deletions GETOOLS_SOURCE/modules/CenterOfMass.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CenterOfMassAnnotations:
projectorXY = _projector + " XY plane"

# Weights
weightsCustom = "Custom weight"
disconnectTargets = "Disconnect selected objects from Center Of Mass"
weightsCustom = "Custom weights"
_weightInfo = "Approximate weight as percentage. In sum all weights should give 100%."
_weightSymmetry = "Select objects on both sides and activate button."
weightHead = _weightInfo
Expand All @@ -48,7 +49,7 @@ class CenterOfMassAnnotations:

class CenterOfMassSettings:
COMRadius = 10 / 3
weightMinMax = (0, 100)
weightMinMax = (1, 10)

# BODYPARTS MAPPING PERCENTAGE
partHead = ("head", 7.3)
Expand All @@ -62,7 +63,7 @@ class CenterOfMassSettings:
partFoot = ("foot", 1.9)

class CenterOfMass:
version = "v0.1.1"
version = "v0.1.2"
name = "CENTER OF MASS"
title = name + " " + version

Expand Down Expand Up @@ -99,6 +100,10 @@ def UILayoutSetup(self, layoutMain, windowWidthMargin, lineHeight):
def UILayoutWeights(self, layoutMain, windowWidthMargin, lineHeight):
self.layoutWeights = cmds.frameLayout(parent = layoutMain, label = "WEIGHTS", collapsable = True)
layoutColumn = cmds.columnLayout(parent = self.layoutWeights, adjustableColumn = True)

count = 1
cmds.gridLayout(parent = layoutColumn, numberOfColumns = count, cellWidth = windowWidthMargin / count, cellHeight = lineHeight)
cmds.button(label = "Disconnect from Center Of Mass", command = self.COMDisconnectTargets, backgroundColor = Colors.red10, annotation = CenterOfMassAnnotations.disconnectTargets)

def PartButton(partInfo = ("", 0), minMaxValue = CenterOfMassSettings.weightMinMax, onlyValue = False, annotation = ""):
value = partInfo[1]
Expand All @@ -108,24 +113,21 @@ def PartButton(partInfo = ("", 0), minMaxValue = CenterOfMassSettings.weightMinM
cmds.button(label = text.format(partInfo[0], value), command = partial(self.COMConstrainToSelected, value), backgroundColor = colorFinal, annotation = annotation)

# WEIGHTS PALETTE
count = 14
count = 10
cmds.gridLayout(parent = layoutColumn, numberOfColumns = count, cellWidth = windowWidthMargin / count, cellHeight = lineHeight)

def CustomButton(value): PartButton(("", value), onlyValue = True, annotation = CenterOfMassAnnotations.weightsCustom)
CustomButton(0)
def CustomButton(value):
PartButton(("", value), onlyValue = True, annotation = CenterOfMassAnnotations.weightsCustom)
CustomButton(1)
CustomButton(2)
CustomButton(3)
CustomButton(4)
CustomButton(5)
CustomButton(6)
CustomButton(7)
CustomButton(8)
CustomButton(9)
CustomButton(10)
CustomButton(20)
CustomButton(30)
CustomButton(40)
CustomButton(50)
CustomButton(60)
CustomButton(70)
CustomButton(80)
CustomButton(90)
CustomButton(100)

# BODYPARTS
count = 3
Expand Down Expand Up @@ -171,7 +173,6 @@ def COMObjectCheck(self, *args):
else:
cmds.warning("Center of mass stored in the script memory, but doesn't exist in the scene. You need to create new COM object or select one in the scene and press \"Activate\" button")
return False

def COMCreate(self, *args):
# self.centerOfMass = cmds.polySphere(name = "myCenterOfMass", subdivisionsX = 8, subdivisionsY = 6, radius = 10)
# self.centerOfMass = Locators.Create("locCenterOfMass", 5)
Expand All @@ -185,24 +186,20 @@ def COMCreate(self, *args):
cmds.setAttr(self.COMObject + ".type", 18)
cmds.setAttr(self.COMObject + ".otherType", "Center Of Mass", type = "string")
cmds.select(self.COMObject)

def COMActivate(self, *args):
# Check selected objects
selectedList = Selector.MultipleObjects(1)
if (selectedList == None):
return
self.COMObject = selectedList[0]

def COMSelect(self, *args):
if (self.COMObjectCheck()):
cmds.select(self.COMObject)

def COMClean(self, *args):
if (self.COMObjectCheck()):
cmds.delete(self.COMObject)
self.COMObject = None
cmds.warning("Last active center of mass object was deleted")

def COMFloorProjection(self, skipAxis = "y", *args):
if (not self.COMObjectCheck()):
return
Expand Down Expand Up @@ -230,7 +227,6 @@ def COMFloorProjection(self, skipAxis = "y", *args):
cmds.parent(joint1, projection)

cmds.select(clear = True)

def COMConstrainToSelected(self, weight, *args):
if (not self.COMObjectCheck()):
return
Expand All @@ -242,18 +238,18 @@ def COMConstrainToSelected(self, weight, *args):

selectedList.append(self.COMObject)
Constraints.ConstrainListToLastElement(reverse = True, selected = selectedList, maintainOffset = False, parent = False, point = True, weight = weight)

# def COMRemove(self, weight, *args): # TODO
# if (self.COMObjectCheck()):
# # Check selected objects
# selectedList = Selector.MultipleObjects(1)
# if (selectedList == None):
# return
def COMDisconnectTargets(self, *args):
if (self.COMObject == None or cmds.objExists(self.COMObject) == False):
cmds.warning("Center Of Mass object is not connected to script. Please select Center Of Mass object and press Activate button before")
return

selectedList = Selector.MultipleObjects(1)
if (selectedList == None):
return

# children = cmds.listRelatives(self.COMObjectRef, type = "constraint")
# if (children > 0):
# attributes = cmds.listAttr(children[0])
# pass
selectedList.append(self.COMObject)
Constraints.DisconnectTargetsFromConstraint(selectedList)
cmds.select(selectedList[:-1], replace = True)


# Baking
Expand All @@ -272,7 +268,6 @@ def BakeScenario2(self, *args):
# return self.BakeAsChildrenFromLastSelected(minSelectedCount = 1)
self.CachedSelectedObjects = Locators.BakeAsChildrenFromLastSelected()
return self.CachedSelectedObjects

def BakeScenario3(self, *args):
objects = self.BakeScenario2()
if (objects == None):
Expand All @@ -281,16 +276,14 @@ def BakeScenario3(self, *args):
self.LinkCached(maintainOffset = False)

return objects

def SelectParent(self, *args):
def BakeCached(self, *args):
if (self.CachedSelectedObjects == None):
cmds.warning("No cached objects yet, operation cancelled")
return
try:
cmds.select(self.CachedSelectedObjects[1][-1])
except:
cmds.warning("Cached object not found")


cmds.select(self.CachedSelectedObjects[0][0:-1])
Baker.BakeSelected()
cmds.delete(self.CachedSelectedObjects[1][-1])

def LinkCached(self, maintainOffset = False, *args):
if (self.CachedSelectedObjects == None):
Expand All @@ -301,13 +294,12 @@ def LinkCached(self, maintainOffset = False, *args):
if (i == len(self.CachedSelectedObjects[0]) - 1):
return
Constraints.ConstrainSecondToFirstObject(self.CachedSelectedObjects[1][i], self.CachedSelectedObjects[0][i], maintainOffset = maintainOffset)

def BakeCached(self, *args):
def SelectParent(self, *args):
if (self.CachedSelectedObjects == None):
cmds.warning("No cached objects yet, operation cancelled")
return

cmds.select(self.CachedSelectedObjects[0][0:-1])
Baker.BakeSelected()
cmds.delete(self.CachedSelectedObjects[1][-1])
try:
cmds.select(self.CachedSelectedObjects[1][-1])
except:
cmds.warning("Cached object not found")

5 changes: 4 additions & 1 deletion GETOOLS_SOURCE/modules/GeneralWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from GETOOLS_SOURCE.modules import Tools as tls

class GeneralWindow:
version = "v0.0.11"
version = "v0.0.12"
name = "GETools"
title = name + " " + version

Expand Down Expand Up @@ -73,9 +73,12 @@ def LayoutMenuBar(self, parentLayout):
def ColorsPalette(*args):
colorCalibration = Colors.ColorsPalette()
colorCalibration.CreateUI()
def PrintChannelBoxAttributes(*args):
print(Selector.GetChannelBoxAttributes())
cmds.menu(label = "Utils", tearOff = True)
cmds.menuItem(label = "Select Transform Hiererchy", command = Selector.SelectTransformHierarchy)
cmds.menuItem(label = "Print selected objects to console", command = Selector.PrintSelected)
cmds.menuItem(label = "Print channel box selected attributes", command = PrintChannelBoxAttributes)
cmds.menuItem(divider = True)
cmds.menuItem(label = "Open Colors Palette", command = ColorsPalette)

Expand Down
31 changes: 12 additions & 19 deletions GETOOLS_SOURCE/modules/Overlappy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
from math import pow, sqrt
from functools import partial

from GETOOLS_SOURCE.values import Enums

from GETOOLS_SOURCE.utils import Animation
from GETOOLS_SOURCE.utils import Baker
from GETOOLS_SOURCE.utils import Colors
from GETOOLS_SOURCE.utils import Constraints
from GETOOLS_SOURCE.utils import Layers
from GETOOLS_SOURCE.utils import MayaSettings
from GETOOLS_SOURCE.utils import Selector
Expand Down Expand Up @@ -98,14 +101,8 @@ class OverlappySettings:
rangeOffsetY = (float("-inf"), float("inf"), 0, 100)
rangeOffsetZ = (float("-inf"), float("inf"), 0, 100)

# CONSTANTS
attributesT = ("tx", "ty", "tz")
attributesR = ("rx", "ry", "rz")
attributesS = ("sx", "sy", "sz")
constraintsNames = ("parentConstraint", "pointConstraint", "orientConstraint", "scaleConstraint", "aimConstraint")

class Overlappy:
version = "v2.0.5"
version = "v2.0.6"
name = "OVERLAPPY"
title = name + " " + version

Expand Down Expand Up @@ -335,7 +332,7 @@ def UILayoutParticleAttributes(self, layoutMain, windowWidthMargin, lineHeight,
menuReset = True,
)
def UILayoutParticleOffset(self, layoutMain, windowWidthMargin, lineHeight, sliderWidth, sliderWidthMarker):
self.layoutOffset = cmds.frameLayout("layoutParticleOffset", label = "PARTICLE OFFSET - use for baking rotation", parent = layoutMain, collapsable = True)
self.layoutOffset = cmds.frameLayout("layoutParticleOffset", label = "PARTICLE OFFSET", parent = layoutMain, collapsable = True)
layoutColumn = cmds.columnLayout(parent = self.layoutOffset, adjustableColumn = True)
# cmds.popupMenu()
# cmds.menuItem(label = "Right-Click") # TODO add reset all function
Expand Down Expand Up @@ -525,7 +522,7 @@ def _SetupCreate(self, objCurrent, *args): # TODO replace locators by locators c

if (self._LoftGetDistance() < OverlappySettings.loftMinDistance):
cmds.setAttr(self.loft[2] + ".visibility", 0)
def _SetupScan(self, *args): # TODO rework
def _SetupScan(self, *args): # TODO rework or delete
# Check overlappy group
if (not cmds.objExists(OverlappySettings.nameGroup)):
cmds.warning("Overlappy object doesn't exists")
Expand Down Expand Up @@ -808,9 +805,9 @@ def _BakeLogic(self, parent, zeroOffsets = False, translation = True, deleteSetu
_item = self.selectedObject

if (translation):
_attributesType = OverlappySettings.attributesT
_attributesType = Enums.Attributes.translateShort
else:
_attributesType = OverlappySettings.attributesR
_attributesType = Enums.Attributes.rotateShort
_attrs = ["", "", ""]

for i in range(len(_attrs)):
Expand All @@ -833,7 +830,7 @@ def _BakeLogic(self, parent, zeroOffsets = False, translation = True, deleteSetu
if(_connections):
for item in _connections:
_type = cmds.nodeType(item)
if(_type in OverlappySettings.constraintsNames):
if(_type in Enums.Constraints.list):
_constrained = True

if(not _locked and _keyable and _settable and not _constrained):
Expand Down Expand Up @@ -870,23 +867,19 @@ def _BakeLogic(self, parent, zeroOffsets = False, translation = True, deleteSetu
_name = "_rebake_" + Text.ConvertSymbols(_item)
_clone = cmds.duplicate(_item, name = _name, parentOnly = True, transformsOnly = True, smartTransform = True, returnRootsOnly = True)

for attr in OverlappySettings.attributesT:
for attr in Enums.Attributes.translateShort:
cmds.setAttr(_clone[0] + "." + attr, lock = False)

for attr in OverlappySettings.attributesR:
for attr in Enums.Attributes.rotateShort:
cmds.setAttr(_clone[0] + "." + attr, lock = False)

cmds.parentConstraint(parent, _clone, maintainOffset = True) # skipTranslate
cmds.select(_clone, replace = True)

# Bake
Baker.BakeSelected(classic = True, preserveOutsideKeys = True)
_children = cmds.listRelatives(_clone, type = "constraint")
for child in _children:
cmds.delete(child)
Constraints.DeleteConstraints(_clone)



# Copy keys, check layer and paste keys
cmds.copyKey(_clone, time = (self.time.values[2], self.time.values[3]), attribute = _attributesFiltered)

Expand Down
12 changes: 10 additions & 2 deletions GETOOLS_SOURCE/modules/Rigging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RiggingAnnotations:
constraintOrient = "Orient constrain.\n{allToLast}".format(allToLast = _textAllSelectedConstrainToLast)
constraintScale = "Scale constrain.\n{allToLast}".format(allToLast = _textAllSelectedConstrainToLast)
constraintAim = "[IN DEVELOPMENT]\nAim constrain.".format(allToLast = _textAllSelectedConstrainToLast) # TODO
constraintDisconnectSelected = "Disconnect targets objects from last selected object. They will be deleted from constraint attributes."
constraintDelete = "Delete all constraints on selected objects"

# Utils
Expand All @@ -38,7 +39,7 @@ class RiggingAnnotations:
copySkinWeights = "Copy skin weights from last selected object to all other selected objects"

class Rigging:
version = "v0.0.2"
version = "v0.0.3"
name = "RIGGING"
title = name + " " + version

Expand All @@ -50,6 +51,7 @@ def UICreate(self, layoutMain):
windowWidthMargin = Settings.windowWidthMargin
lineHeight = Settings.lineHeight


# CONSTRAINTS
layoutConstraints = cmds.frameLayout(parent = layoutMain, label = "CONSTRAINTS", collapsable = True)
layoutColumnConstraints = cmds.columnLayout(parent = layoutConstraints, adjustableColumn = True)
Expand All @@ -70,8 +72,9 @@ def UICreate(self, layoutMain):
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)
#
countOffsets = 1
countOffsets = 2
cmds.gridLayout(parent = layoutColumnConstraints, numberOfColumns = countOffsets, cellWidth = windowWidthMargin / countOffsets, cellHeight = lineHeight)
cmds.button(label = "Disconnect", command = self.DisconnectTargetsFromConstraint, backgroundColor = Colors.red50, annotation = RiggingAnnotations.constraintDisconnectSelected)
cmds.button(label = "Delete Constraints", command = self.DeleteConstraints, backgroundColor = Colors.red50, annotation = RiggingAnnotations.constraintDelete)


Expand Down Expand Up @@ -110,4 +113,9 @@ def DeleteConstraints(self, *args):
if (selectedList == None):
return
Constraints.DeleteConstraints(selectedList)
def DisconnectTargetsFromConstraint(self, *args):
selectedList = Selector.MultipleObjects(2)
if (selectedList == None):
return
Constraints.DisconnectTargetsFromConstraint(selectedList)

8 changes: 4 additions & 4 deletions GETOOLS_SOURCE/modules/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
windowName = "windowGETools"
dockName = "dockGETools"
dockAllowedAreas = ["left", "right"]
dockStartArea = dockAllowedAreas[0] # used for start docking state, 0 - left, 1 - right
dockStartArea = dockAllowedAreas[0] # start docking state, 0 - left, 1 - right

windowHeight = 500 # used for vertical window size when undocked
windowWidth = 320
windowHeight = 500 # vertical window size when undocked
windowWidth = 280
windowWidthScrollSpace = 20
lineHeight = 30
margin = 2

sliderWidth = (60, 60, 10)
sliderWidth = (60, 54, 10)
sliderWidthMarker = 14

windowWidthScroll = windowWidth - windowWidthScrollSpace
Expand Down
Loading

0 comments on commit 32c2d29

Please sign in to comment.