0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

シーンのアニメーションを一気にオフセット

0
Last updated at Posted at 2025-12-18

mayaのシーンでアニメーションのキーフレームのフレーム位置を一気にうごかしたいなぁと

UIでできるんだからスクリプトでいけるじゃろ というラフな考えで。

keyframeまわりだからこの辺ですいねぇ

setKeyframeはキーの追加ですね。

keyframeはアニメーションカーブノードに対してあれこれできそうな・・・ 

timeChange こんなオプションがありました。

x (時間)軸に沿ったキーの(時間入力アニメーション カーブ上での)移動量(-relative で)または移動場所(-absolute で)を指定します。照会すると float[] を返します。

これで時を操れそうですね。

キーフレームの指定方法はいくつかありそうですが、今回は indexをつかってみます。

indexes = cmds.keyframe(animCurveNode,q=True,keyframeCount=True)
cmds.keyframe(animCurveNode,e=True,option = "over",index = (0,indexes-1),relative =True,timeChange=offsetTime)

とりあえずテストしてみましょうか。

こんなシーンで

image.png

import maya.cmds as cmds
animCurveNode = "pSphere1_translateX"
offsetTime = -89
indexes = cmds.keyframe(animCurveNode,q=True,keyframeCount=True)
cmds.keyframe(animCurveNode,e=True,option = "over",index = (0,indexes-1),relative =True,timeChange=offsetTime)

お、動いてますね。
image.png

これをシーン全体となるとー
アニメーションカーブノードをごそっと取得して実行ですかねぇ


import maya.cmds as cmds
animCurveNodes = cmds.ls(type = "animCurve")
offsetTime = -89

for animCurveNode in animCurveNodes:
    indexes = cmds.keyframe(animCurveNode,q=True,keyframeCount=True)
    cmds.keyframe(animCurveNode,e=True,option = "over",index = (0,indexes-1),relative =True,timeChange=offsetTime)

これをー
image.png

こう
image.png

とりあえずできましたね。

雑感

  • cmds.ls(type = "animCurve") だとドリブンキーも拾っちゃう?
  • アニメーションカーブノードはリファレンスされてる物だとエラー起きるので除外しないと
  • シーン全体じゃなくて オブジェクト単位でオフセット出来たら便利かも?
  • valueChange というオプションも気になる
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?