def frameGraphEditor(centerCurrentTime=False): ''' If graph editor has focus, frame the selected or visible animation curves. ''' panel = mc.getPanel(up=True) if not panel: panel = mc.getPanel(withFocus=True) if not panel: return False panelType = mc.getPanel(to=panel) if panelType != 'scriptedPanel': return False scriptedType = mc.scriptedPanel(panel, query=True, type=True) if scriptedType != 'graphEditor': return False graphEditor = panel + 'GraphEd' keySel = utl.KeySelection() if keySel.selectedKeys(): pass elif keySel.visibleInGraphEditor(): pass if keySel.selected: times = keySel.getSortedKeyTimes() start = times[0] end = times[-1] else: keySel.frameRange() start = keySel._timeRangeStart end = keySel._timeRangeEnd values = sorted(keySel.keyframe(query=True, valueChange=True)) minValue = values[0] maxValue = values[-1] if start == end: start = start - 1 end = end + 1 if maxValue == minValue: minValue = minValue - 0.5 maxValue = maxValue + 0.5 #add a 10% padding timePadding = (end - start) / 10.0 valuePadding = (maxValue - minValue) / 10.0 mc.animView(graphEditor, startTime=start - timePadding, endTime=end + timePadding, minValue=minValue - valuePadding, maxValue=maxValue + valuePadding) if centerCurrentTime: mc.animCurveEditor(graphEditor, edit=True, lookAt='currentTime') return True
def frameGraphEditor(centerCurrentTime=False): ''' If graph editor has focus, frame the selected or visible animation curves. ''' panel = mc.getPanel(up=True) if not panel: panel = mc.getPanel(withFocus=True) if not panel: return False panelType = mc.getPanel(to=panel) if panelType != 'scriptedPanel': return False scriptedType = mc.scriptedPanel(panel, query=True, type=True) if scriptedType != 'graphEditor': return False graphEditor = panel+'GraphEd' keySel = utl.KeySelection() if keySel.selectedKeys(): pass elif keySel.visibleInGraphEditor(): pass if keySel.selected: times = keySel.getSortedKeyTimes() start = times[0] end = times[-1] else: keySel.frameRange() start = keySel._timeRangeStart end = keySel._timeRangeEnd values = sorted(keySel.keyframe(query=True, valueChange=True)) minValue = values[0] maxValue = values[-1] if start == end: start = start-1 end = end+1 if maxValue == minValue: minValue = minValue-0.5 maxValue = maxValue+0.5 #add a 10% padding timePadding = (end-start)/10.0 valuePadding = (maxValue-minValue)/10.0 mc.animView(graphEditor, startTime=start-timePadding, endTime=end+timePadding, minValue=minValue-valuePadding, maxValue=maxValue+valuePadding) if centerCurrentTime: mc.animCurveEditor(graphEditor, edit=True, lookAt='currentTime') return True
def framePlaybackRangeFn(rangeStart=None, rangeEnd=None): from aTools.commonMods import animMod; reload(animMod) animMod.filterNonAnimatedCurves() if not rangeStart: rangeStart = cmds.playbackOptions(query=True, minTime=True) -1 rangeEnd = cmds.playbackOptions(query=True, maxTime=True) +1 val = getMinMax(rangeStart, rangeEnd) minVal = val[0] maxVal = val[1] cmds.animView('graphEditor1GraphEd', startTime=rangeStart, endTime=rangeEnd, minValue=minVal, maxValue=maxVal)
def framePlaybackRangeFn(rangeStart=None, rangeEnd=None): from aTools.commonMods import animMod reload(animMod) animMod.filterNonAnimatedCurves() if not rangeStart: rangeStart = cmds.playbackOptions(query=True, minTime=True) - 1 rangeEnd = cmds.playbackOptions(query=True, maxTime=True) + 1 val = getMinMax(rangeStart, rangeEnd) minVal = val[0] maxVal = val[1] cmds.animView('graphEditor1GraphEd', startTime=rangeStart, endTime=rangeEnd, minValue=minVal, maxValue=maxVal)
def frameRange(): """ //Frame time range in graph/dopesheet string $panType = `getPanel -withFocus`; { if ($panType == "dopeSheetPanel1") { animView -startTime (`playbackOptions -query -minTime` - 8) -endTime (`playbackOptions -query -maxTime` + 8) dopeSheetPanel1DopeSheetEd; } else animView -startTime (`playbackOptions -query -minTime` - 8) -endTime (`playbackOptions -query -maxTime` + 8) graphEditor1GraphEd; } """ panType = cmds.getPanel(wf=True) animStart = int(cmds.playbackOptions(q=True, min=True)) animEnd = int(cmds.playbackOptions(q=True, max=True)) if panType == "dopeSheetPanel1": cmds.animView('dopeSheetPanel1DopeSheetEd', st=animStart - 5, et=animEnd + 5) elif panType == "graphEditor1": cmds.animView('graphEditor1GraphEd', st=animStart - 5, et=animEnd + 5)
def matchTime(self): cmds.animView(startTime=self.startTime - self.bookends, endTime=self.endTime + self.bookends)
def matchRange(self): cmds.animView(startTime=self.minTime - self.bookends, endTime=self.maxTime + self.bookends)