#!bpy"""Name: 'Flying Letters'Blender: 2.7xGroup: 'Animation'Tooltip: 'Helperscripts to animate letters'"""importbpyimportrandomdeftextToSingleLetters(text="Hallo",x_start=0,y_start=0):""" A given text line is divided in single letters (objects). """counter=1kerning=.1pos_next_x=0forletterintext:name="row_%s_%s"%(y_start,counter)myFontCurve=bpy.data.curves.new(type="FONT",name=name)myFontOb=bpy.data.objects.new(name,myFontCurve)myFontOb.location=(x_start+pos_next_x,y_start,0)myFontOb.data.body=letterbpy.context.scene.objects.link(myFontOb)bpy.context.scene.update()counter+=1pos_next_x=pos_next_x+myFontOb.dimensions.x+kerningdefdefineEndPosition():""" Register endposition of all text objects. This is the Position of each letter after creation. """data={}all=[item.nameforiteminbpy.data.objects]fornameinall:ifname[0:3]=="row":obj=bpy.data.objects[name]data[name]=[(obj.location.x,obj.location.y,obj.location.z)]returndatadefcalcStartPosition(d=None):""" Calculate random start position of all text objects. """all=[item.nameforiteminbpy.data.objects]fornameinall:ifname[0:3]=="row":obj=bpy.data.objects[name]randX=round(random.uniform(-4,4),3)randY=round(random.uniform(10,30),3)randZ=round(random.uniform(10,30),3)d[name].append((randX,randY,randZ))returnddefcalcStartEndFrames(d=None,startFrame=10,endFrame=190):""" Calculate random startframe for each object. """passdefsetkeyframes(d=None):""" One line describing the task of this function """passif__name__=='__main__':bpy.ops.object.select_by_type(type='FONT')bpy.ops.object.delete()textToSingleLetters("Python",y_start=-1,x_start=-2)textToSingleLetters("Blender",y_start=0,x_start=-2)textToSingleLetters("Blend4Web",y_start=1,x_start=-2)d=defineEndPosition()d=calcStartPosition(d)print(d)

PyMove3D credits

PyMove3D is started and supported by the German Python Software Verband.
It delivers course material for the programming contest and for people
interested in using Python and Blender.