1
$\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
  • 2
    $\begingroup$ consider using a track to constraint on the text to the camera. $\endgroup$
    – batFINGER
    May 12, 2019 at 8:18

1 Answer 1

3
$\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
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .