fork download
  1. import bpy
  2.  
  3. scene = bpy.context.scene
  4. obj = scene.objects['Text']
  5. font_curve = obj.data
  6.  
  7. #print(str)
  8.  
  9. def recalculate_text(scene):
  10. Curve_length=1934
  11. FrameNumber = scene.frame_current
  12. #bpy.data.objects["Empty"].constraints["Follow Path"].offset_factor
  13. AnimationData = bpy.data.objects['Empty'].animation_data.action.fcurves[0]
  14. current = AnimationData.evaluate(FrameNumber)
  15. print("current:",current)
  16.  
  17. previous = AnimationData.evaluate(FrameNumber-1)
  18. print("previous:",previous)
  19.  
  20. difference=current-previous
  21. meter_per_seconds=Curve_length*difference*30 #30frame
  22. kilometer_per_hour=(meter_per_seconds*3600)/1000 #kph
  23. str="%.2f Km/h" % kilometer_per_hour
  24.  
  25. font_curve.body = str
  26.  
  27. def register():
  28. bpy.app.handlers.frame_change_post.append(recalculate_text)
  29.  
  30. def unregister():
  31. bpy.app.handlers.frame_change_post.remove(recalculate_text)
  32.  
  33. register()
Runtime error #stdin #stdout #stderr 0.15s 23620KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
    import bpy
ModuleNotFoundError: No module named 'bpy'