I know that I can use the blf
module to draw 2d text, but is there a method to draw text at certain positions in 3d space?
I want to add a text right to a specific point in 3d.
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityThx, I found an example in the MeasureIt addon and here is some code from my Fast Carve addon to draw 2d text:
rv3d = self._view_context.region_3d
region = self._view_context.region
pos_text = location_3d_to_region_2d(region, rv3d, self._center)
blf.position(2, pos_text[0], pos_text[1], 0)
blf.draw(2, "r: {0:.3f}".format(self._radius))
This is a script that adds text at position x,y,z and the text says "my text"
import bpy
bpy.ops.object.text_add(location=(x,y,z))
ob=bpy.context.object
ob.data.body = "my text"
blf.rotation(..)
(and aspect) to rotate text on screen. I remember fiddling with this and accidentally rotated all the GUI text too. (oops meant to comment under answer comment) $\endgroup$