Skip to content

Commit

Permalink
Added and fixed functions (#15, #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevisanGMW committed Nov 11, 2020
1 parent 8701c40 commit f2f8edd
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions python-scripts/gt_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
@Guilherme Trevisan - [email protected] - 2020-09-13
Functions were named with a "gtu" (GT Utilities) prefix to avoid conflicts.
1.1 - 2020/10/17
1.1 - 2020-10-17
Added move pivot to bottom/top
Added copy/paste material
Added move to origin
1.2 - 2020/10/21
1.2 - 2020-10-21
Updated reset transform to better handle translate
Added Uniform LRA Toggle
Changed the order of the functions to match the menu
1.3 - 2020-11-11
Updates "gtu_import_references" to better handle unloaded references
Added "gtu_remove_references"
To Do:
Add proper error handling to all functions.
New functions:
Expand Down Expand Up @@ -52,7 +56,7 @@
from PySide.QtGui import QIcon, QWidget

# Script Version
gtu_script_version = "1.2"
gtu_script_version = "1.3"

''' ____________________________ General Functions ____________________________'''
def gtu_reload_file():
Expand All @@ -76,12 +80,41 @@ def gtu_open_resource_browser():
def gtu_import_references():
''' Imports all references '''
try:
errors = ''
refs = cmds.ls(rf=True)
for i in refs:
r_file = cmds.referenceQuery(i, f=True)
cmds.file(r_file, importReference=True)
try:
r_file = cmds.referenceQuery(i, f=True)
cmds.file(r_file, importReference=True)
except Exception as e:
errors += str(e) + '(' + r_file + ')\n'
except:
cmds.warning("Something went wrong. Maybe you don't have any references to import?") # Handle this better...
cmds.warning("Something went wrong. Maybe you don't have any references to import?")
if errors != '':
cmds.warning('Not all references were imported. Open the script editor for more information.')
print(('#' * 50) + '\n')
print(errors)
print('#' * 50)


def gtu_remove_references():
''' Removes all references '''
try:
errors = ''
refs = cmds.ls(rf=True)
for i in refs:
try:
r_file = cmds.referenceQuery(i, f=True)
cmds.file(r_file, removeReference=True)
except Exception as e:
errors += str(e) + '(' + r_file + ')\n'
except:
cmds.warning("Something went wrong. Maybe you don't have any references to import?")
if errors != '':
cmds.warning('Not all references were removed. Open the script editor for more information.')
print(('#' * 50) + '\n')
print(errors)
print('#' * 50)


def gtu_uniform_lra_toggle():
Expand Down Expand Up @@ -445,6 +478,7 @@ def close_help_gui():
#gtu_reload_file()
#gtu_open_resource_browser()
#gtu_import_references()
#gtu_remove_references()
#gtu_uniform_lra_toggle()

#gtu_copy_material()
Expand Down

0 comments on commit f2f8edd

Please sign in to comment.