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.

  • $\begingroup$ Do you mean on the 2D projection of a 3D location, as in, for example, the MeasureIt addon, or in full perspective? Or.. in perspective, but always facing the viewpoint? $\endgroup$ – Robin Betts Apr 23 '19 at 7:49
  • $\begingroup$ Thx, I found an example in the MeasureIt addon $\endgroup$ – Jayanam Apr 25 '19 at 8:56
  • $\begingroup$ @RobinBetts can set 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$ – batFINGER Apr 25 '19 at 11:48

Thx, 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))
| improve this answer | |
  • 4
    $\begingroup$ I was hoping you would ;) ... perhaps, if there's a short enough chunk of code to clue other readers in, you could paste it into your answer, to make it 'BSE complete' $\endgroup$ – Robin Betts Apr 25 '19 at 9:04
  • 1
    $\begingroup$ @RobinBetts: I added the Python snippet from my addon $\endgroup$ – Jayanam May 8 '19 at 5:09

This is a script that adds text at position x,y,z and the text says "my text"

import bpy
ob.data.body = "my text"
| improve this answer | |

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.