Hello,
I want to display in the viewport property without using the modal operation. is it possible ? I found it, but I did not understand how I can use (I started with python)
Thank you
import bpy
import blf
class DrawingClass:
def __init__(self, context, prop):
self.prop = prop
self.handle = bpy.types.SpaceView3D.draw_handler_add(
self.draw_text_callback,(context,),
'WINDOW', 'POST_PIXEL')
def draw_text_callback(self, context):
font_id = 0 # XXX, need to find out how best to get this.
# draw some text
blf.position(font_id, 15, 50, 0)
blf.size(font_id, 20, 72)
blf.draw(font_id, "%s %s" % (context.scene.name, self.prop))
def remove_handle(self):
bpy.types.SpaceView3D.draw_handler_remove(self.handle, 'WINDOW')
context = bpy.context
dc = DrawingClass(context, "Draw This On Screen")
#dc.remove_handle() # will remove the handle and stop drawing
There is this template also here:
Blender\2.76\scripts emplates_py\operator_modal_draw.py