Skip to content

Commit

Permalink
Merge pull request #206 from TrevisanGMW/dev
Browse files Browse the repository at this point in the history
release <- dev (3.4.0)
  • Loading branch information
TrevisanGMW committed Sep 2, 2024
2 parents ff7ca4e + 1954af8 commit 856330f
Show file tree
Hide file tree
Showing 1,237 changed files with 52,041 additions and 28,046 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ We **love** detailed bug reports!

## Code Style

- The code style should follow the [PEP8](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings) patterns as often as possible.
- Docstring format used is [Google Docs](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings). Arguments and returns should be included whenever possible.
- The code style should follow the [PEP8](https://peps.python.org/pep-0008/) patterns as often as possible.
- Docstring format used is [Google Style Docstrings](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings). Arguments and returns should be included.
- Make sure to add new utilities and user interface functions and classes to the correct script categories. <br>For example, if it's an animation class/function, add it to "anim_utils.py" so it can be easily found.
- Follow [best practices](https://refactoring.guru/refactoring/smells), such as avoiding bloated code, or minimizing coupling between components.
- Use Python, other languages should only be used if an option in Python is not available.
Expand Down
8 changes: 4 additions & 4 deletions gt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys

# Package Variables
__version_tuple__ = (3, 3, 1)
__version_suffix__ = ''
__version__ = '.'.join(str(n) for n in __version_tuple__) + __version_suffix__
__authors__ = ['Guilherme Trevisan']
__version_tuple__ = (3, 4, 0)
__version_suffix__ = ""
__version__ = ".".join(str(n) for n in __version_tuple__) + __version_suffix__
__authors__ = ["Guilherme Trevisan"]

# Python Version Dependency
if sys.version_info.major < 3:
Expand Down
3 changes: 2 additions & 1 deletion gt/utils/__init__.py → gt/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Utilities
Core Modules
github.com/TrevisanGMW - 2020-09-13
"""

import sys
import os

Expand Down
24 changes: 13 additions & 11 deletions gt/utils/alembic_utils.py → gt/core/alembic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""
Alembic Utilities
github.com/TrevisanGMW/gt-tools
Alembic Module
Code Namespace:
core_alembic # import gt.core.alembic as core_alembic
"""
from gt.utils.transform_utils import Transform, Vector3

from gt.core.transform import Transform, Vector3
from math import degrees
import maya.cmds as cmds
import logging
Expand Down Expand Up @@ -50,7 +53,7 @@ def get_alembic_nodes():
Returns:
List of alembic nodes in the scene. Empty list if nothing was found.
"""
return cmds.ls(typ='AlembicNode', long=True) or []
return cmds.ls(typ="AlembicNode", long=True) or []


def get_alembic_cycle_as_string(alembic_node):
Expand All @@ -63,8 +66,9 @@ def get_alembic_cycle_as_string(alembic_node):
"""
cycle_string = ["Hold", "Loop", "Reverse", "Bounce"]
if not cmds.objExists(f"{alembic_node}.cycleType"):
logger.debug(f'Unable to get cycle as string. Missing alembic alembic_node attribute: '
f'"{alembic_node}.cycle_type".')
logger.debug(
f"Unable to get cycle as string. Missing alembic alembic_node attribute: " f'"{alembic_node}.cycle_type".'
)
return
alembic_cycle = cmds.getAttr(f"{alembic_node}.cycleType")
if alembic_cycle is not None and alembic_cycle <= len(cycle_string):
Expand Down Expand Up @@ -109,7 +113,7 @@ def get_root_node(alembic_node):
"""
root_node = alembic_node
for history in cmds.listHistory(alembic_node, future=True):
if cmds.objectType(history) == 'transform':
if cmds.objectType(history) == "transform":
root_node = history
return root_node

Expand All @@ -124,9 +128,7 @@ def get_root_transform(self, alembic_node):
return Transform()
trans = Transform()
trans.set_position(xyz=translation)
rot = Vector3(x=degrees(rotation[0]),
y=degrees(rotation[1]),
z=degrees(rotation[2]))
rot = Vector3(x=degrees(rotation[0]), y=degrees(rotation[1]), z=degrees(rotation[2]))
trans.set_rotation(xyz=rot)
trans.set_scale(xyz=scale)
return trans
Expand All @@ -135,11 +137,11 @@ def get_root_transform(self, alembic_node):
if __name__ == "__main__":
logger.setLevel(logging.DEBUG)
from pprint import pprint

# import maya.standalone
# maya.standalone.initialize()
node = get_alembic_nodes()[0]
alembic = AlembicNode(node)
out = None
out = alembic.transform
pprint(out)

53 changes: 31 additions & 22 deletions gt/utils/anim_utils.py → gt/core/anim.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""
Animation Utilities
Animation Module
Code Namespace:
core_anim # import gt.core.anim as core_anim
"""
from gt.utils.feedback_utils import FeedbackMessage

from gt.core.feedback import FeedbackMessage
import maya.cmds as cmds
import logging

Expand All @@ -18,10 +22,10 @@ def get_time_keyframes():
Returns:
list: number of keyframes deleted during the operation
"""
keys_ta = cmds.ls(type='animCurveTA') or [] # time-angle (default keys - time as input)
keys_tl = cmds.ls(type='animCurveTL') or [] # time-distance
keys_tt = cmds.ls(type='animCurveTT') or [] # time-time
keys_tu = cmds.ls(type='animCurveTU') or [] # time-double
keys_ta = cmds.ls(type="animCurveTA") or [] # time-angle (default keys - time as input)
keys_tl = cmds.ls(type="animCurveTL") or [] # time-distance
keys_tt = cmds.ls(type="animCurveTT") or [] # time-time
keys_tu = cmds.ls(type="animCurveTU") or [] # time-double

time_keyframes = keys_ta + keys_tl + keys_tt + keys_tu
return time_keyframes
Expand All @@ -34,10 +38,10 @@ def get_double_keyframes():
Returns:
list: number of keyframes deleted during the operation
"""
keys_ul = cmds.ls(type='animCurveUL') or [] # double-distance - Driven Keys (double as input)
keys_ua = cmds.ls(type='animCurveUA') or [] # double-angle
keys_ut = cmds.ls(type='animCurveUT') or [] # double-time
keys_uu = cmds.ls(type='animCurveUU') or [] # double-double
keys_ul = cmds.ls(type="animCurveUL") or [] # double-distance - Driven Keys (double as input)
keys_ua = cmds.ls(type="animCurveUA") or [] # double-angle
keys_ut = cmds.ls(type="animCurveUT") or [] # double-time
keys_uu = cmds.ls(type="animCurveUU") or [] # double-double

double_keyframes = keys_ul + keys_ua + keys_ut + keys_uu
return double_keyframes
Expand All @@ -49,7 +53,7 @@ def delete_time_keyframes():
Returns:
list: number of keyframes deleted during the operation
"""
function_name = 'Delete Time Keyframes'
function_name = "Delete Time Keyframes"
cmds.undoInfo(openChunk=True, chunkName=function_name)
deleted_counter = 0
try:
Expand All @@ -60,11 +64,13 @@ def delete_time_keyframes():
except Exception as e:
logger.debug(str(e))

feedback = FeedbackMessage(quantity=deleted_counter,
singular="keyframe node was",
plural="keyframe nodes were",
conclusion="deleted.",
zero_overwrite_message='No keyframes found in this scene.')
feedback = FeedbackMessage(
quantity=deleted_counter,
singular="keyframe node was",
plural="keyframe nodes were",
conclusion="deleted.",
zero_overwrite_message="No keyframes found in this scene.",
)
feedback.print_inview_message()
return deleted_counter
except Exception as e:
Expand All @@ -80,7 +86,7 @@ def delete_double_keyframes():
Returns:
int: number of keyframes deleted during the operation
"""
function_name = 'Delete Double Keyframes'
function_name = "Delete Double Keyframes"
cmds.undoInfo(openChunk=True, chunkName=function_name)
deleted_counter = 0
try:
Expand All @@ -91,11 +97,13 @@ def delete_double_keyframes():
except Exception as e:
logger.debug(str(e))

feedback = FeedbackMessage(quantity=deleted_counter,
singular="driven keyframe node was",
plural="driven keyframe nodes were",
conclusion="deleted.",
zero_overwrite_message='No driven keyframes found in this scene.')
feedback = FeedbackMessage(
quantity=deleted_counter,
singular="driven keyframe node was",
plural="driven keyframe nodes were",
conclusion="deleted.",
zero_overwrite_message="No driven keyframes found in this scene.",
)
feedback.print_inview_message()
return deleted_counter
except Exception as e:
Expand All @@ -108,6 +116,7 @@ def delete_double_keyframes():
if __name__ == "__main__":
logger.setLevel(logging.DEBUG)
from pprint import pprint

out = None
out = delete_time_keyframes()
pprint(out)
Loading

0 comments on commit 856330f

Please sign in to comment.