5
5
# / __ `__ \/ / Licensed under Creative Commons BY-SA
6
6
# / / / / / / / http://creativecommons.org/licenses/by-sa/3.0/
7
7
# /_/ /_/ /_/_/ _________
8
- # /_________/ Revision 29 , 2017-04-25
8
+ # /_________/ Revision 30 , 2017-06-13
9
9
# _______________________________
10
10
# - -/__ Installing Python Scripts __/- - - - - - - - - - - - - - - - - - - -
11
11
#
34
34
__author__ = 'Morgan Loomis'
35
35
__license__ = 'Creative Commons Attribution-ShareAlike'
36
36
__category__ = 'animationScripts'
37
- __revision__ = 29
37
+ __revision__ = 30
38
38
39
39
import maya .cmds as mc
40
40
import maya .mel as mm
50
50
icon_path = os .path .join (os .path .dirname (__file__ ),'icons' ).replace ('\\ ' ,'/' )
51
51
if os .path .isdir (icon_path ) and icon_path not in os .environ ['XBMLANGPATH' ]:
52
52
os .environ ['XBMLANGPATH' ] = os .pathsep .join ((os .environ ['XBMLANGPATH' ],icon_path ))
53
-
53
+
54
+ MAYA_VERSION = mm .eval ('getApplicationVersionAsFloat' )
54
55
55
56
def _showHelpCommand (url ):
56
57
'''
@@ -213,7 +214,7 @@ def createHotkey(command, name, description='', python=True):
213
214
Open up the hotkey editor to create a hotkey from the specified command
214
215
'''
215
216
216
- if mm . eval ( 'getApplicationVersionAsFloat' ) > 2015 :
217
+ if MAYA_VERSION > 2015 :
217
218
print "Creating hotkeys currently doesn't work in the new hotkey editor."
218
219
print "Here's the command, you'll have to make the hotkey yourself (sorry):"
219
220
print command
@@ -229,7 +230,7 @@ def createHotkey(command, name, description='', python=True):
229
230
mc .textField ('HotkeyEditorDescriptionField' , edit = True , text = description )
230
231
231
232
if python :
232
- if mm . eval ( 'getApplicationVersionAsFloat' ) < 2013 :
233
+ if MAYA_VERSION < 2013 :
233
234
command = 'python("' + command + '");'
234
235
else : #2013 or above
235
236
mc .radioButtonGrp ('HotkeyEditorLanguageRadioGrp' , edit = True , select = 2 )
@@ -269,10 +270,10 @@ def createShelfButton(command, label='', name=None, description='',
269
270
shelfTab = gShelfTopLevel + '|' + shelfTab
270
271
271
272
#add additional args depending on what version of maya we're in
272
- kwargs = dict ()
273
- if mm . eval ( 'getApplicationVersionAsFloat' ) >= 2009 :
273
+ kwargs = {}
274
+ if MAYA_VERSION >= 2009 :
274
275
kwargs ['commandRepeatable' ] = True
275
- if mm . eval ( 'getApplicationVersionAsFloat' ) >= 2011 :
276
+ if MAYA_VERSION >= 2011 :
276
277
kwargs ['overlayLabelColor' ] = labelColor
277
278
kwargs ['overlayLabelBackColor' ] = labelBackgroundColor
278
279
if backgroundColor :
@@ -435,7 +436,7 @@ def getHoldTangentType():
435
436
return 'linear' ,'linear'
436
437
if tangentType == 'step' :
437
438
return 'linear' ,'step'
438
- if tangentType == 'plateau' or tangentType == 'spline' or mm . eval ( 'getApplicationVersionAsFloat' ) < 2012 :
439
+ if tangentType == 'plateau' or tangentType == 'spline' or MAYA_VERSION < 2012 :
439
440
return 'plateau' ,'plateau'
440
441
return 'auto' ,'auto'
441
442
@@ -447,7 +448,7 @@ def getIcon(name):
447
448
'''
448
449
449
450
ext = '.png'
450
- if mm . eval ( 'getApplicationVersionAsFloat' ) < 2011 :
451
+ if MAYA_VERSION < 2011 :
451
452
ext = '.xpm'
452
453
453
454
if not name .endswith ('.png' ) and not name .endswith ('.xpm' ):
@@ -632,14 +633,14 @@ def matchBake(source=None, destination=None, bakeOnOnes=False, maintainOffset=Fa
632
633
OpenMaya .MGlobal .displayWarning ('No attributes to bake!' )
633
634
return
634
635
635
- duplicates = dict ()
636
- keytimes = dict ()
636
+ duplicates = {}
637
+ keytimes = {}
637
638
constraint = list ()
638
- itt = dict ()
639
- ott = dict ()
640
- weighted = dict ()
641
- itw = dict ()
642
- otw = dict ()
639
+ itt = {}
640
+ ott = {}
641
+ weighted = {}
642
+ itw = {}
643
+ otw = {}
643
644
#initialize allKeyTimes with start and end frames, since they may not be keyed
644
645
allKeyTimes = [start ,end ]
645
646
for s ,d in zip (source ,destination ):
@@ -656,12 +657,12 @@ def matchBake(source=None, destination=None, bakeOnOnes=False, maintainOffset=Fa
656
657
657
658
#set up our data dictionaries
658
659
duplicates [d ] = dup
659
- keytimes [d ] = dict ()
660
- itt [d ] = dict ()
661
- ott [d ] = dict ()
662
- weighted [d ] = dict ()
663
- itw [d ] = dict ()
664
- otw [d ] = dict ()
660
+ keytimes [d ] = {}
661
+ itt [d ] = {}
662
+ ott [d ] = {}
663
+ weighted [d ] = {}
664
+ itw [d ] = {}
665
+ otw [d ] = {}
665
666
666
667
#if we're baking on ones, we don't need keytimes
667
668
if not bakeOnOnes :
@@ -811,10 +812,8 @@ def renderShelfIcon(name='tmp', width=32, height=32):
811
812
812
813
mc .setAttr ('defaultRenderGlobals.currentRenderer' , 'mayaSoftware' , type = 'string' )
813
814
814
- mayaVersion = mm .eval ('getApplicationVersionAsFloat' )
815
-
816
815
imageFormat = 50 #XPM
817
- if mayaVersion >= 2011 :
816
+ if MAYA_VERSION >= 2011 :
818
817
imageFormat = 32 #PNG
819
818
820
819
mc .setAttr ('defaultRenderGlobals.imageFormat' , imageFormat )
@@ -996,20 +995,24 @@ class IsolateViews():
996
995
'''
997
996
998
997
def __enter__ (self ):
999
-
1000
- self .sel = mc .ls (sl = True )
1001
- self .modelPanels = mc .getPanel (type = 'modelPanel' )
1002
-
1003
- #unfortunately there's no good way to know what's been isolated, so in this case if a view is isolated, skip it.
1004
- self .skip = list ()
1005
- for each in self .modelPanels :
1006
- if mc .isolateSelect (each , query = True , state = True ):
1007
- self .skip .append (each )
1008
-
1009
- self .isolate (True )
1010
-
1011
- mc .select (clear = True )
1012
-
998
+
999
+ if MAYA_VERSION >= 2016.5 :
1000
+ if not mc .ogs (query = True , pause = True ):
1001
+ mc .ogs (pause = True )
1002
+ else :
1003
+ self .sel = mc .ls (sl = True )
1004
+ self .modelPanels = mc .getPanel (type = 'modelPanel' )
1005
+
1006
+ #unfortunately there's no good way to know what's been isolated, so in this case if a view is isolated, skip it.
1007
+ self .skip = list ()
1008
+ for each in self .modelPanels :
1009
+ if mc .isolateSelect (each , query = True , state = True ):
1010
+ self .skip .append (each )
1011
+
1012
+ self .isolate (True )
1013
+
1014
+ mc .select (clear = True )
1015
+
1013
1016
self .resetAutoKey = mc .autoKeyframe (query = True , state = True )
1014
1017
mc .autoKeyframe (state = False )
1015
1018
@@ -1019,11 +1022,15 @@ def __exit__(self, *args):
1019
1022
#reset settings
1020
1023
mc .autoKeyframe (state = self .resetAutoKey )
1021
1024
1022
- if self .sel :
1023
- mc .select (self .sel )
1024
-
1025
- self .isolate (False )
1026
-
1025
+ if MAYA_VERSION >= 2016.5 :
1026
+ if mc .ogs (query = True , pause = True ):
1027
+ mc .ogs (pause = True )
1028
+ else :
1029
+ if self .sel :
1030
+ mc .select (self .sel )
1031
+
1032
+ self .isolate (False )
1033
+
1027
1034
1028
1035
def isolate (self , state ):
1029
1036
@@ -1860,7 +1867,7 @@ def about(self, *args):
1860
1867
mc .confirmDialog (title = self .name , message = text , button = 'Close' )
1861
1868
1862
1869
1863
- def buttonWithPopup (self , label = None , command = None , annotation = '' , shelfLabel = '' , shelfIcon = 'render_useBackground' , readUI_toArgs = dict () ):
1870
+ def buttonWithPopup (self , label = None , command = None , annotation = '' , shelfLabel = '' , shelfIcon = 'render_useBackground' , readUI_toArgs = {} ):
1864
1871
'''
1865
1872
Create a button and attach a popup menu to a control with options to create a shelf button or a hotkey.
1866
1873
The argCommand should return a kwargs dictionary that can be used as args for the main command.
@@ -1967,7 +1974,7 @@ def _populateSelectionList(self, channel, control, *args):
1967
1974
1968
1975
class ButtonWithPopup ():
1969
1976
1970
- def __init__ (self , label = None , name = None , command = None , annotation = '' , shelfLabel = '' , shelfIcon = 'render_useBackground' , readUI_toArgs = dict () , ** kwargs ):
1977
+ def __init__ (self , label = None , name = None , command = None , annotation = '' , shelfLabel = '' , shelfIcon = 'render_useBackground' , readUI_toArgs = {} , ** kwargs ):
1971
1978
'''
1972
1979
The fancy part of this object is the readUI_toArgs argument.
1973
1980
'''
@@ -2117,7 +2124,7 @@ def __init__(self, force=False):
2117
2124
2118
2125
def __enter__ (self ):
2119
2126
'''open the undo chunk'''
2120
- if self .force or mm . eval ( 'getApplicationVersionAsFloat' ) < 2011 :
2127
+ if self .force or MAYA_VERSION < 2011 :
2121
2128
self .force = True
2122
2129
mc .undoInfo (openChunk = True )
2123
2130
@@ -2296,3 +2303,5 @@ def cross(self, other):
2296
2303
# Revision 28: 2017-03-20 : bug fix and support for ml_puppet
2297
2304
#
2298
2305
# Revision 29: 2017-04-25 : matchBake support input frames
2306
+ #
2307
+ # Revision 30: 2017-06-13 : unify version test, isolate view update
0 commit comments