10
$\begingroup$

I would like to "animate" a string custom property (a date), to have the explicit date ("10-05-2005" for example) attached to an object, over the time. Blender says me that my custom string property cannot be animated even if I declare it ANIMATABLE when declaring it like that:

bpy.types.Object.Date = bpy.props.StringProperty(name="Date" options={'ANIMATABLE'})  

Any idea to make it work?

Thanks for the help,

Salvatore

$\endgroup$
1
  • 4
    $\begingroup$ Yes, it can't be animated with blender's animation system. You could however use a frame_change handler (or maybe also a driver) to change the text property accordingly. Check out the available text addons, like the type writer script. $\endgroup$
    – CodeManX
    Commented Oct 12, 2013 at 23:15

2 Answers 2

10
$\begingroup$

It's possible, but you're going to have to "animate" with Python. There's no way to animate property values using the Dope Sheet or Graph Editor. Assuming you have the default cube and you've given it a custom string property called MyString (through the interface... this would also work for custom properties defined with Python; it's just easier to see what's happening this way), you could write a handler that's triggered by the frame_change_pre event. It would look like so:

import bpy

def animate_string(scene):
    ob = bpy.data.objects['Cube']

    if scene.frame_current < 25:
        ob['MyString'] = "First bit text"
    elif 25 <= scene.frame_current < 46:
        ob['MyString'] = "Next text part"
    elif 46 <= scene.frame_current < 100:
        ob['MyString'] = "Another bit of text"
    else:
        ob['MyString'] = "Text after frame 99"

bpy.app.handlers.frame_change_pre.append(animate_string)

Now... if you want to be clever and still animate using the Dope Sheet, Graph Editor, or even the Timeline, you could probably extend this with some clever code that populates your string property with the string stored in a marker (e.g. find the closest marker less than the current frame and use the String stored there). If you only have one object in your scene that needs to be animated this way, it should work great.

A caveat... In my testing (r60747), you could only watch the custom property change values if you scrub through one frame at a time (Left Arrow and Right Arrow). Playing back animation with Alt+A works (you can check with a print statement), but the value doesn't update in the interface. In fact, when I put my mouse cursor in the Properties Editor while playing back with Alt+A, it crashes Blender (bug report submitted).

$\endgroup$
1
$\begingroup$

Use the index switch with the set of strings. Index Switch

$\endgroup$

You must log in to answer this question.

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