I use blender 2.6 and add a text object with
bpy.ops.object.text_add(location=(x,y,z))
and just want to set the text and cannot figure that out. I found in the python console that I can
bpy.data.texts['Text.001'].write("my text")
but (also generally) am confused how to reference the last created object to perform something on it. In tutorials there is the primitive_MESHTYPE_add
shortcuts which return not the object created. Can you tell me how to do Text.new()
?
How to add or change text in Blender. To add a text object, we press Shift+A in the 3D viewport and choose text. To change the text we then press Tab to go into edit mode. We can now erase the default text and write anything we want.
Most areas of Blender can be scripted, including animation, rendering, import and export, object creation and automating repetitive tasks. To interact with Blender, scripts can make use of the tightly integrated API .
bpy.ops.object.text_add()
ob=bpy.context.object
ob.data.body = "my text"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With