移動先: 概要 戻り値 関連項目. フラグ. Python 例.

概要

keyframe( [objects] , [absolute=boolean], [adjustBreakdown=boolean], [animation=string], [attribute=string], [breakdown=boolean], [controlPoints=boolean], [eval=boolean], [float=floatrange], [floatChange=float], [hierarchy=string], [includeUpperBound=boolean], [index=uint], [indexValue=boolean], [keyframeCount=boolean], [lastSelected=boolean], [name=boolean], [option=string], [relative=boolean], [selected=boolean], [shape=boolean], [tickDrawSpecial=boolean], [time=timerange], [timeChange=time], [valueChange=float])

注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。

keyframe は 「元に戻す」が可能、「照会」が可能、「編集」が可能 です。

このコマンドは、キーセット上に作用します。キーセットは、1 つまたは複数のアニメーション カーブ上の指定したタイム レンジ内のキー グループとして定義されます。

キーセットを構成するアニメーション カーブは、「-animation」フラグの値に依存します。

-animation フラグを使用して、「translateX」など attributeName という形式の引数を取る、多目的な -attribute フラグによって固有に識別されるカーブをオーバーライドすることができます。

アニメーション カーブ上の各キーは、カーブの時間値またはインデックスによって識別されます。時間とインデックスは、単独にあるいはリストの一部または範囲として指定することができます。

範囲の一方の値を省略した場合は、次の例のように、範囲が「無限であること」を意味します。

このコマンドは、指定されたオブジェクトまたはパラメータ カーブにおけるキーの時間または値を編集します。

別途、「-query」フラグで指定されていない限り、このコマンドはデフォルトでキーフレームを編集します。

戻り値

int(下記に記述があるもの以外)キーが修正されたカーブの数。照会モードでは、このコマンドは、下記の照会可能なフラグで記述されたとおり、さまざまなオブジェクトを返すことがあります。

戻り値の型は照会モードでは照会フラグが基になります。

関連項目

copyKey, cutKey, findKeyframe, keyTangent, keyframeOutliner, keyframeStats, pasteKey, scaleKey, setInfinity, snapKey

フラグ

absolute, adjustBreakdown, animation, attribute, breakdown, controlPoints, eval, float, floatChange, hierarchy, includeUpperBound, index, indexValue, keyframeCount, lastSelected, name, option, relative, selected, shape, tickDrawSpecial, time, timeChange, valueChange
ロング ネーム(ショート ネーム) 引数型 プロパティ
attribute(at) string createmultiuse
選択するアトリビュートのリストです。

このフラグは照会モードでは値が必要になります。

hierarchy(hi) string create
階層展開オプションです。有効な値は、「above」、「below」、「both」、「none」です。(「pasteKey」コマンドでは無効)。

このフラグは照会モードでは値が必要になります。

shape(s) boolean create
トランスフォームの下にあるシェイプのアトリビュート(「controlPoints」以外)も考慮します。デフォルト: true(「pasteKey」コマンドでは無効)。

このフラグは照会モードでは値が必要になります。

controlPoints(cp) boolean create
このフラグは、アトリビュートのリストにシェイプの制御点を含めるかどうかを明示的に指定します(「-s」フラグを参照)。 デフォルト: false(「pasteKey」コマンドでは無効)。

このフラグは照会モードでは値が必要になります。

index(index) uint createmultiuse
アニメーション カーブ上のキーのインデックス

このフラグは照会モードでは値が必要になります。

time(t) timerange createmultiuse
時間ベースのアニメーション カーブ上の キー(またはキー レンジ)を固有に表す時間です。有効な timeRange は、単一の値(-t 10)、または上下限をコロンで区切った文字列(-t "10:20")です。

このフラグは照会モードでは値が必要になります。

float(f) floatrange createmultiuse
時間ベースの animCurve上の時間ベースでないキー(またはキー レンジ)を固有に表す値です。有効な floatRange は、単一の値(-f 10)、または上下限をコロンで区切った文字列(-f "10:20")です。

このフラグは照会モードでは値が必要になります。

includeUpperBound(iub) boolean create
-t/time または -f/float フラグがキーの範囲を表す場合に、範囲の上限のキーをキーセットに含めるかどうかを定義します。 デフォルト値: true。 このフラグは、-t/time フラグの引数が上下限が指定したタイム レンジである場合に限り有効です(「pasteKey」コマンドでこのフラグを使用するときに「replace」、「fitReplace」、「scaleReplace」などのオプションを指定すると、このフラグは、置き換えられるターゲット カーブの時間範囲のみを参照します。このフラグは、クリップボードからペーストされたカーブには影響しません)。
animation(an) string create
このコマンドが、自身が影響を与えるアニメーションを取得する場所です。有効な値は「objects」、「keys」、「keysOrObjects」で、デフォルトは「keysOrObjects」です(詳細については、説明を参照してください)。
absolute(a) boolean create
移動量は絶対値です。
relative(r) boolean create
移動量は、キーの現行位置を基準にして相対値です。
timeChange(tc) time createqueryedit
x(時間)軸に沿ったキーの(時間入力アニメーション カーブ上での)移動量(-relative で)または移動場所(-absolute で)を指定します。照会すると float[] を返します。
floatChange(fc) float createqueryedit
x(float)軸に沿ったキーの(非時間入力アニメーション カーブ上での)移動量(-relative で)または移動場所(-absolute で)を指定します。照会すると float[] を返します。
indexValue(iv) boolean createquery
キーのインデックスに対して整数を返す照会専用のフラグです。
valueChange(vc) float createqueryedit
y(値)軸に沿ったキーの移動量(-relative で)または移動場所(-absolute で)を指定します。照会すると float[] を返します。
option(o) string createedit
有効な値は、「move」、「insert」、「over」、「segmentOver」です。キーに「move」を設定しても、そのキーは前後でほかのキーを越えては移動しません。キーを「insert」すると、(-timeChange の値に応じて)その前後にあるキーがすべて、同等の量、移動します。キーを「over」すると、このキーは(他のキーがその場所に既に存在しない限り)いつでも移動することができます。 複数のキーのセットを「segmentOver」すると(このオプションは、複数のキーを移動する場合のみ、明らかなエフェクトを生み出します)、タイム レンジを指定しない限り、(時間的に)最初のキーと、最後のキーにより、セグメントが定義されます。その後、このセグメントは他のキーの上に移動できるようになり、このセグメントのための余地を作るために、キーは移動します。
adjustBreakdown(abd) boolean create
false のときは、キーを移動してもブレークダウン タイミングは保持されません。true(デフォルト)のときは、ブレークダウン タイミング リレーションが保持されるように調整されます。
breakdown(bd) boolean createqueryedit
キーのブレークダウン状態を設定します。整数を返します。デフォルトは false です。 キーのブレークダウン状態は、-tc や -fc フラグを使ったキーの移動コマンドでは設定できません。
tickDrawSpecial(tds) boolean createedit
タイム スライダの表示がキー マークに変わると、このキーに特殊な描画状態が設定されます。
keyframeCount(kc) boolean createquery
ターゲット用に見つかったキーの数に対して整数を返します。
name(n) boolean createquery
指定したノード、アトリビュート、キーのアニメーション カーブの名前を返します。
eval(ev) boolean createquery
入力コネクションと無関係に、-t/time または -f/float フラグで指定される時間で評価されるときのアニメーション カーブの値を返します。他の照会フラグと一緒に使ったり、タイム レンジ(-t "5:10")と共に使うことはできません。 コマンド ラインに -t または -f フラグが使われていないとき、eval はカレント タイムに照会されます。照会すると float[] を返します。
selected(sl) boolean createquery
このフラグが照会で使われた場合、どんなアクティブなキーに対しても要求された値を返します。
lastSelected(lsl) boolean createquery
このフラグが照会で使われた場合、最後に選択したキーに対して要求された値を返します。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

Python 例

import maya.cmds as cmds

# Two ways to find out how many keys there are on the
# paramCurve connected to surface1.translateX;
#
cmds.keyframe( 'surface1', attribute='translateX', query=True, keyframeCount=True )
cmds.keyframe( 'surface1.translateX', query=True, keyframeCount=True )

# Query all keyframes of object "surface1" within the time range 0 to 20.
#
cmds.keyframe( 'surface1', time=(0,20), query=True, valueChange=True, timeChange=True);

# Query just the time of the first key in the
# "Translate X" parameter curve.  Note that the indices are 0-based.
#
cmds.keyframe('surface1.translateX',index=(0,0),query=True);

# Shift all the active object's keys in the range 10-20
# by one (current) time unit (frame, second, etc.)
#
cmds.keyframe(edit=True,relative=True,timeChange=1,time=(10,20))

# Two ways to move all keys at time 10 of
# the active object to time 12.  Note that "-absolute"
# is the default.
#
cmds.keyframe(time=(10,10),timeChange=12)
cmds.keyframe(time=(10,10),absolute=True,timeChange=12)

# Set the 2nd keyframe of cube1's Translate X parameter
# curve to be 10.25 at time 1.5 seconds.
#
cmds.keyframe('surface1.translateX',edit=True,index=(1,1),timeChange='1.5sec',valueChange=10.25)

# Evaluate the animCurve feeding into nurbsCone1's translateX attribute at time 3
#
cmds.keyframe('nurbsCone1',at='tx',t=(3,3),q=True,eval=True)

# Query the times of the active keys on attribute translateX of nurbsCone1
#
cmds.keyframe( 'nurbsCone1', at='tx', sl=True, q=True, tc=True )

# How many keys are selected on nurbsCone1?
#
cmds.keyframe( 'nurbsCone1', sl=True, q=True, kc=True )

# Here's a script to print out all a cone's animCurves that have
# keys selected.  Each animCurve is followed by a list of times
# for the selected keys.  The result of this script is:
#     nurbsCone1_translateX: 5
#     nurbsCone1_translateY: 12
#     nurbsCone1_translateZ: 4 14
#
myCone = cmds.cone()
cmds.setKeyframe( myCone[0], t=[0,5,10], at='tx', v=5 )
cmds.setKeyframe( myCone[0], t=[2,7,12], at='ty', v=10 )
cmds.setKeyframe( myCone[0], t=[4,9,14], at='tz', v=15 )
cmds.selectKey( t=[(5,5),(12,12),(4,4)] )
cmds.selectKey( animation='objects', add=True, t=(14,14) )

nodes = cmds.keyframe(myCone,query=True,name=True)
for node in nodes:
   keyTimes = cmds.keyframe(node,sl=True,query=True,tc=True)
   print "Node: %s" % node
   print keyTimes

# For the above sample script, the last selected key is
# nurbsCone1_translateZ: 14.  The following may be used to query
# the values for that key
#
cmds.keyframe( query=True, lastSelected=True, name=True )
cmds.keyframe( query=True, lastSelected=True, timeChange=True )
cmds.keyframe( query=True, lastSelected=True, valueChange=True )