I want to show some Info in the viewport something like vertex indices
you can see select a vertex and press N to see vertex position but it's hard.
so I liked to write a script to show the vertex position
I tried to use opengl but text was blurry and I couldn't make what I want.
# import stand alone modules
import blf
import bpy
font_info = {
"font_id": 0,
"handler": None,
}
def init():
"""init function - runs once"""
import os
# Create a new font object, use external ttf file.
font_path = bpy.path.abspath('//Zeyada.ttf')
# Store the font indice - to use later.
if os.path.exists(font_path):
font_info["font_id"] = blf.load(font_path)
else:
# Default font.
font_info["font_id"] = 0
# set the font drawing routine to run every frame
font_info["handler"] = bpy.types.SpaceView3D.draw_handler_add(
draw_callback_px, (None, None), 'WINDOW', 'POST_VIEW')
def draw_callback_px(self, context):
"""Draw on the viewports"""
# BLF drawing routine
font_id = font_info["font_id"]
#blf.position(font_id, pos.x, pos.y, pos.z)
#blf.size(font_id, 100,100)
#blf.draw(font_id, "Hello World")
pos = bpy.context.object.location
v3d = context.space_data
rv3d = v3d.region_3d
pos_text = location_3d_to_region_2d(region, rv3d, context._center)
blf.position(font_id, pos_text[0], pos_text[1], 0)
blf.size(font_id, 100,100)
blf.draw(font_id, "Hello World")
if __name__ == '__main__':
init()
ob.matrix_world.translation
which may or may not beob.location
See blender.stackexchange.com/questions/6155/… New edit are passingNone
ascontext
argument, yet trying to use it, which will throw errors to console. $\endgroup$