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

  • 4
    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. – CoDEmanX Oct 12 '13 at 23:15

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).

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.