Skip to content

Commit

Permalink
Merge pull request #11 from assumptionsoup/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
assumptionsoup authored and Guppy Animation Tools Updater committed Dec 6, 2017
2 parents e759152 + 95419ee commit 7afe5d4
Show file tree
Hide file tree
Showing 9 changed files with 1,858 additions and 662 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ attributes. To disable this, you can use the option:

python("cleverKeys.setKey(useSelectedCurves = False)");

If you would like Clever Keys limit keys when curves are selected, but
want this behavior whenever you select any part of a curve (keyframe,
tangent or the entire curve), you can enable this:

python("cleverKeys.setKey(usePartialCurveSelection = True)");

In Maya 2011 and later it is very easy to clear a channel selection.
You just have to click away from the channel. Before 2010 things were
a little trickier. To help with this, I've added the clear command,
Expand Down
40 changes: 38 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,49 @@
'selectedAttributes',
'slideAnimationKeys',
'zeroSelection',
'guppyInstaller']
'renameIt']
_logRegister = {}
_logLevels = {}
_debugOn = False


def getLogger(name):
if 'guppy_animation_tools' in name:
name = name.replace('guppy_animation_tools', 'gat', 1)
return plogging.getLogger(name)
if name not in _logRegister:
log = plogging.getLogger(name)
log.setLevel(log.INFO)
_logRegister[name] = log

return _logRegister[name]


def setLoggerLevels(level, namespaces=None):
if namespaces is None:
namespaces = _logRegister.keys()

if _logLevels:
namespaces = [n for n in _logLevels.iterkeys() if n not in namespaces]

for name in namespaces:
_logLevels[name] = _logRegister[name].level
_logRegister[name].setLevel(level)


def restoreLoggerLevels():
global _logLevels
for name, level in _logLevels.iteritems():
_logRegister[name].setLevel(level)
_logLevels = {}


def toggleDebug():
global _debugOn
if _debugOn:
restoreLoggerLevels()
else:
setLoggerLevels(plogging.DEBUG)
_debugOn = not _debugOn


def _addToPath(env, newLocation):
Expand Down
37 changes: 29 additions & 8 deletions scripts/cleverKeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,39 @@ def toggleDebug():
selectedAttributes.toggleDebug()


def setKey(insert=True, useSelectedCurves=True):
def setKey(insert=True, useSelectedCurves=True, usePartialCurveSelection=False):
'''Sets clever keys. Hohoho.
If the mouse is over the graph editor, it keys the attributes selected
there. Otherwise it keys the attributes selected in the channel box. If
the channelBox is closed it will key all the attributes on the selected
node. It attempts to use the "Insert Key" function which makes keys match
the curvature of the surrounding keys whenever possible. Set insert
parameter to false to disable this behavior.'''
If the mouse is over the graph editor, it keys the attributes
selected there. Otherwise it keys the attributes selected in the
channel box. If the channelBox is closed it will key all the
attributes on the selected node. By default this uses the "Insert
Key" behavior of Maya which makes keys match the curvature of the
surrounding keys whenever possible. Set insert parameter to false
to disable this behavior.
Parameters
----------
insert : bool
If true, uses the "insert key" behavior of Maya when creating keys.
In this mode, key tangents will match any existing curves leaving
them undisturbed.
useSelectedCurves : bool
If true, when an entire animation curve is selected in the graph
editor (by clicking on the curve, not a key or tangent, or
selecting every keyframe on the curve), then a key will only be
inserted on the curves, other visible curves will be left alone.
usePartialCurveSelection : bool
This modifies the behavior of useSelectedCurves, and only
affects behavior when that parameter is true as well. When true,
this changes useSelectedCurves, so that selecting any part of a
curve will limit keys to that curve (you do not need to select
the entire curve). Unselected curves will be left alone.
'''

# Get Attributes
attributes = selectedAttributes.get(detectionType='cursor', useSelectedCurves=useSelectedCurves)
attributes = selectedAttributes.get(detectionType='cursor', useSelectedCurves=useSelectedCurves, usePartialCurveSelection=usePartialCurveSelection)
currentFrame = cmd.currentTime(q=1)

# Make extra sure attributes are unique (they should already be)
Expand Down
Loading

0 comments on commit 7afe5d4

Please sign in to comment.