keyframing text, how?

I’m modelling a spacecraft cockpit right now, as an asset for multiple uses rather than just for a specific animation. Amongst the details are various screens which will display text, such as the engine power output(many, many gigawatts) or the delta V remaining, or the current acceleration,etc. The screens have dials and such but also spaces for text, so far i’m modelling it all in sketchup before blender import. upon blender import i would like to add in some “objects” for text on those screens which can change overtime (as the power needle rotates around the dial i want to show the text below going up with the digits changing for example). I don’t want to have to have hundreds of text objects being whizzed around and brought in from out of view when needed before being moved out of view themselves when replaced so is there a way to make one text object that i can put in place (perhaps one object fro each digit in each numerical display) where i can keyframe the words in the text such that at frame X the object reads “4” and then at frame X+1 the object now reads"5". the same object would be used for all values of the digit and only it’s content would change. is there a way to do this? i want to avoid using a separate object for each digit because there are more than twenty different boxes on the display with numbers in them, if i had to have 10 objects (objects for the digits 0 to 9) for each box then i would be dealing with a huge number of objects before i’ve even begun with all the other parts of the model. and i can’t use different materials for each digit and then keyframe their transparency as that would mean hundreds of materials. i need an object that can change the identity of the digit it is displaying with just one keyframe.
please advise.

can anyone advise on this,please. i still haven’t found a solution to the problem and not having one is limiting what parts of the cockpit i can model until i know whether this is possible or not.
thank you

thank you for your suggestions. i would very much like to know how you did it. if possible i’d rather you just described the constraints you used(did you use constraints?) than posted a script. what i need isn’t so much one that does all the values but a system where i can have a digit as an object and change it say from “5” to “1” or any other digit i please in one keyframe without having to rush in another digit model from off-screen. the font i was using for my digits was going to be a type of “agency fb bold” but if the effect can only be done with an led counter style font that will be alright. to clarify i don’t need something that will do the counting up for me, i can happily keyframe the change in the numerical value of each digit for myself. what i am discussing is an “object” which can display a different digit each time it is keyframed, not to count but to instantly snap from showing a given digit in one frame to another digit(of my choosing) in another frame. if you can give an explanation of your LED counter effect which is slightly more detailed it would help very much.
effectively i’m asking for a way to keyframe the content(i want to leave the materials the same, leave the object in the same place but alter the actual text it is showing) of a “text object”. the thing is changing the words of the text(which can just as easily be a single numerical digit for each digit position on my HUD display) is done in edit mode and i cannot find a way to keyframe stuff that is done in edit mode.
thank you for your input so far.

Here’s the hello world of changing a text object with python:

Open a new blend
Add a text object
Rename the object From “Text” to “TextObject” (optional really)
Make one of you windows a text editor (widen the text editor a little bit)
Click the new button
Copy these 2 lines of code and paste them into the text editor

import bpy["TextObject"].data.body = 'foo123'

Click the ‘runs script’ button. Or hit alt-p

The text changes…

The script I use is only slightly more complicated, the script gets the x position of an empty, and changes the string to the integer value.

Here is the most basic version of the script, I’ll include a sample blend. You can incorporate it into your scene If you want to test it. Here’s how:

  1. In your scene, rename one of your text objects to ‘TextObject’
  2. Add an empty and name it ‘EmptyTextObject’
  3. Move the empty to the x location of value you want the text to display initially and insert a ketframe ‘Loc’
  4. Go to another frame, say frame 10 and move the empty to thex location of the value you want the text to display, keyframe 'loc;
  5. Open a text editor, click the new button.
  6. Paste this code in:

import bpy

def my_handler(scene):
    newtext = str(int(['EmptyTextObject'].location.x))["TextObject"].data.body = newtext

Hit ‘run script button’ (or alt-p)

scrub the time line, the text object will display whatever x location the empty is at.

Every frame the code gets the empty’s x location, it converts it an integer (it ignores the decimal, or mantissa, and then converts that integer to a string.

It then then assigns that string to the text object.

In this sample blend empty on frame 1 is keyframed at x=0
frame 9 x=0 , so the text displays 0 for frames 1 through 9

on frame 10 it is keyframed for x=3, text now diplays 3
and frame 19 x=3 so for frames 1-19 text displays 3

on frame 30? x=-5, so it starts ‘counting down’
text-11.blend (585 KB)