0
$\begingroup$

I was wondering what the python script the following sequence would look like. I'd like to be able to run the code in the text editor instead of manually doing it every time I need a new animation.

For a selected armature > clear all keyframes for scale x,y,z > and change the scale values to .011? In order to make sure that the scale is .011 through the whole animation.

Thank you very much for your time, enter image description hereI'd really appreciate the help!

$\endgroup$

1 Answer 1

1
$\begingroup$

Try this. Select the armature before running it (but the mode shouldn't matter this time).

import bpy
ob = bpy.context.active_object
assert ob.type == 'ARMATURE'
assert ob.animation_data and ob.animation_data.action
action = ob.animation_data.action
for fc in [*action.fcurves]:
    if fc.data_path == "scale":
        action.fcurves.remove(fc)
ob.scale = [0.011] * 3
$\endgroup$
5
  • $\begingroup$ Well, it did something lol. Not exactly what it was supposed to, looks like the armature disappeared. Here's a link to the test file with the armature in question: drive.google.com/file/d/1-QGTIa7qmaGfaoyoxq0iASE3rqC1g-hQ/… If there is no way to achieve this, it's probably fine, but it would save a lot of time if we could find a way to get it to work :( $\endgroup$
    – GoodNight
    Commented Sep 3, 2020 at 0:24
  • $\begingroup$ Oh, you only want to do it to the object itself? That script did it for all the bones. It's even easier to do it just for the object, but it doesn't seem like it would save much time. I'll update... $\endgroup$
    – scurest
    Commented Sep 3, 2020 at 0:34
  • $\begingroup$ Oh yeah, just the entire armature object, it's true it only shaves a few seconds, BUT if I'm doing it every day, multiple times a day, those seconds count. Works perfectly :) Out of curiosity, if I wanted to combine this code with the bone rename code from the last post into a single script, do I just add them together? Or what would that look like? $\endgroup$
    – GoodNight
    Commented Sep 3, 2020 at 0:58
  • 1
    $\begingroup$ Pasting them one after is a bit crude but will work fine. $\endgroup$
    – scurest
    Commented Sep 3, 2020 at 1:04
  • $\begingroup$ Thank you, all my problems have been perfectly resolved. I've hope you have a wonderful day, and much appreciate the clear and concise code you've provided :) $\endgroup$
    – GoodNight
    Commented Sep 3, 2020 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .