0
$\begingroup$

I want to add a text to an object, soft of like a label. The thing is, when I do it with python, view_align=True doesn't work. The text keeps it's original orientation.

I'm not writing a plugin or anything, I have the script in a text file in blender and just run it.

I'm thinking that the view isn't active when I run the script and because of that the text doesn't know what view to orient towards.

Maybe I could find the rotation of the camera and use that to set the rotation of the text object.

$\endgroup$
  • 1
    $\begingroup$ consider using a track to constraint on the text to the camera. $\endgroup$ – batFINGER May 12 '19 at 8:18
1
$\begingroup$

I got the idea while writing my question. I'm not very good at 3D math with matrices etc but it worked.

Maybe someone will be helped by this.

cam_rot = scene.camera.rotation_euler
bpy.ops.object.text_add(location=(x,y,z))
textobject=bpy.context.object
textobject.rotation_euler = cam_rot
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.