Skip to content

Commit

Permalink
Merge pull request #191 from TrevisanGMW/dev-feature/proxy_components
Browse files Browse the repository at this point in the history
Auto Rigger utilities
  • Loading branch information
TrevisanGMW authored Sep 27, 2023
2 parents 767666f + c689495 commit 8affaed
Show file tree
Hide file tree
Showing 15 changed files with 1,841 additions and 433 deletions.
6 changes: 4 additions & 2 deletions gt/utils/attr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,19 @@ def get_multiple_attr(attribute_path=None, obj_list=None, attr_list=None, enum_a
return attribute_values


def get_trs_attr_as_list(obj):
def get_trs_attr_as_list(obj, verbose=True):
"""
Gets Translate, Rotation and Scale values as a list
Args:
obj (str): Name of the source object
verbose (bool, optional): If active, it will return a warning when the object is missing.
Returns:
list or None: A list with TRS values in order [TX, TY, TZ, RX, RY, RZ, SX, SY, SZ], None if missing object.
e.g. [0, 0, 0, 15, 15, 15, 1, 1, 1]
"""
if not obj or not cmds.objExists(obj):
logger.warning(f'Unable to get TRS channels as list. Unable to find object "{obj}".')
if verbose:
logger.warning(f'Unable to get TRS channels as list. Unable to find object "{obj}".')
return
output = []
for channel in DEFAULT_CHANNELS: # TRS
Expand Down
179 changes: 179 additions & 0 deletions gt/utils/data/curves/_rig_root.crv
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"name": "root",
"transform": null,
"shapes": [
{
"name": "root_ctrlCircleShape",
"points": [
[
-11.7,
0.0,
45.484
],
[
-16.907,
0.0,
44.279
],
[
-25.594,
0.0,
40.072
],
[
-35.492,
0.0,
31.953
],
[
-42.968,
0.0,
20.627
],
[
-47.157,
0.0,
7.511
],
[
-47.209,
0.0,
-6.195
],
[
-43.776,
0.0,
-19.451
],
[
-36.112,
0.0,
-31.134
],
[
-26.009,
0.0,
-39.961
],
[
-13.56,
0.0,
-45.63
],
[
0.0,
0.0,
-47.66
],
[
13.56,
0.0,
-45.63
],
[
26.009,
0.0,
-39.961
],
[
36.112,
0.0,
-31.134
],
[
43.776,
0.0,
-19.451
],
[
47.209,
0.0,
-6.195
],
[
47.157,
0.0,
7.511
],
[
42.968,
0.0,
20.627
],
[
35.492,
0.0,
31.953
],
[
25.594,
0.0,
40.072
],
[
16.907,
0.0,
44.279
],
[
11.7,
0.0,
45.484
]
],
"degree": 3,
"knot": null,
"periodic": 0,
"is_bezier": false
},
{
"name": "root_ctrlArrowShape",
"points": [
[
-11.7,
0.0,
45.484
],
[
-11.7,
0.0,
59.009
],
[
-23.4,
0.0,
59.009
],
[
0.0,
0.0,
82.409
],
[
23.4,
0.0,
59.009
],
[
11.7,
0.0,
59.009
],
[
11.7,
0.0,
45.484
]
],
"degree": 1,
"knot": null,
"periodic": 0,
"is_bezier": false
}
],
"metadata": {
"projectionAxis": "persp",
"projectionScale": 5,
"projectionFit": null
}
}
21 changes: 17 additions & 4 deletions gt/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ def progress_callback(current_file, total_files):
return extracted_files_list


def on_rm_error(func, file_path, exc_info):
"""
Handle an error encountered during file removal.
Args:
func (callable): The function that raised the exception.
file_path (str): The path of the file that couldn't be removed.
exc_info (tuple): A tuple containing exception information.
"""
logger.debug(f'Function that raised exception: "{str(func)}".')
logger.debug(f'Exception info: "{str(exc_info)}".')
logger.debug(f'An exception was raised during a "rm" (remove) operation. Attempting again with new permissions...')
os.chmod(file_path, stat.S_IWRITE)
os.unlink(file_path)


def delete_paths(paths):
"""
Deletes files or folders at the specified paths.
Expand Down Expand Up @@ -319,7 +335,7 @@ def delete_paths(paths):
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)
shutil.rmtree(path, onerror=on_rm_error)
except OSError as e:
logger.debug(f'Unable to delete "{path}". Issue: {e}')
if not os.path.exists(path):
Expand Down Expand Up @@ -388,6 +404,3 @@ def make_empty_file(path):

if __name__ == "__main__":
logger.setLevel(logging.DEBUG)
from pprint import pprint
out = None
pprint(out)
9 changes: 7 additions & 2 deletions gt/utils/naming_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def get_long_name(short_name):
try:
long_name = cmds.ls(short_name, long=True)[0]
return long_name
except IndexError:
return None
except (IndexError, RuntimeError) as e:
logger.debug(f'Unable to retrieve long name. Issue: {str(e)}')
return None


def get_short_name(long_name, remove_namespace=False):
Expand All @@ -98,3 +99,7 @@ def get_short_name(long_name, remove_namespace=False):
if remove_namespace:
output_short_name = output_short_name.split(":")[-1]
return output_short_name


if __name__ == "__main__":
logger.setLevel(logging.DEBUG)
Loading

0 comments on commit 8affaed

Please sign in to comment.