Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

blender script: how to write to text object

Tags:

python

blender

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()?

like image 698
groovehunter Avatar asked Jun 30 '13 09:06

groovehunter


People also ask

How do I edit text in Blender?

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.

Does Blender support scripting?

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 .


1 Answers

bpy.ops.object.text_add()
ob=bpy.context.object
ob.data.body = "my text"
like image 197
retroj Avatar answered Sep 26 '22 22:09

retroj