1

I am trying to script with Python FBX SDK to scale models. And I am using LclScaling.Set() to set scale value. But I found if this model has keyframes, then the scaling is not applied.

So my question is how to properly scale models that have keyframes. Here is my code:

scale = node.LclScaling.Get()
value = 0.5
node.LclScaling.Set(fbx.FbxDouble3(scale[0] * value, scale[1] * value, scale[2] * value))
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
LOOK2001
  • 55
  • 4
  • I figured it out. In Maya, if I set translate or rotate keyframes, the scale property would also has Animation Node in FBX SDK. So, if I want to modify scale property, I should use SetChannelValue or FbxAnimCurveFilterScale instead of LclScaling.Set() – LOOK2001 Jul 17 '20 at 07:28

2 Answers2

1

In case you can't scale your model that already has animation keyframes, it seems that it has keyframes on a Scale parameter, even if scale is not changing during playback session. That could be possible in situation when user animates just a position of a model pressing S shortcut. This shortcut generates 10 keyframes at a time, but only translation/rotation keyframes are important for you here.

enter image description here

Solution:

Delete redundant keyframes in Graph Editor manually or programmatically.

import maya.cmds as cmds

cmds.cutKey('pSphere1', time=(1,100), attribute='scaleX', option="keys")
cmds.cutKey('pSphere1', time=(1,100), attribute='scaleY', option="keys")
cmds.cutKey('pSphere1', time=(1,100), attribute='scaleZ', option="keys")

After this you can easily scale your model.

P.S.

The other appropriate way is to update old scale keyframes for FBX model (first in the beginning and second in the end of animation).

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • 1
    Thanks! It is really helpful! I eliminate some problems by your method, but I still get that problem. For example, the model has rotation keyframes and I ensure there are not scale keyframes, then it's scale value still cannot be changed by my script. Maybe I can add scale keyframes for those models to fix that problem. And are there any differences between mesh and skeleton? Thanks again! – LOOK2001 Jun 28 '20 at 14:42
  • I believe that character's mesh has to be managed by skeleton. So all keyframes must be assigned to skeleton (except deformer's keyframes). – Andy Jazz Jun 28 '20 at 14:49
  • BTW, do you know how to enable autocomplete for Python FBX SDK in editor? – LOOK2001 Jun 30 '20 at 08:32
0

I figured it out. In Maya, if I set translate or rotate keyframes, the scale property would also has Animation Node in FBX SDK. So, if I want to modify scale property, I should use SetChannelValue or FbxAnimCurveFilterScale instead of LclScaling.Set()

LOOK2001
  • 55
  • 4