Hello!
I repurposed the script for displaying status if correct face attribute is on.
It works fine, but has some issue.
It won’t update status if I check and uncheck settings, only after some viewport moves/updates.
I’m wondering if some could help me solve this issue?
import blf
import bpy
class DrawingClass:
def __init__(self, prop):
from bpy import context
self.prop = prop
self.handle = bpy.types.SpaceView3D.draw_handler_add(
self.draw_text_callback, (), 'WINDOW', 'POST_PIXEL')
def draw_text_callback(self):
from bpy import context
if not hasattr(context, "scene"):
return None
mode = bpy.context.active_object.mode
type = bpy.context.active_object.type
correctuv = bpy.context.scene.tool_settings.use_transform_correct_face_attributes
if correctuv and mode =="EDIT" and type == 'MESH':
display = True
else:
display = False
if display:
font_id = 0 # XXX, need to find out how best to get this.
color1 = (0.77, 0.624, 0.66, 1.0)
width = context.area.width
blf.size(font_id, 40, 50)
dim_x = blf.dimensions(font_id, self.prop)[0]/2
blf.position(font_id, width/2-dim_x, 18, 0)
blf.color(font_id, *color1)
blf.draw(font_id, f"{self.prop}")
def remove_handle(self):
from bpy import context
bpy.types.SpaceView3D.draw_handler_remove(self.handle, 'WINDOW')
dc = None
def register():
global dc
dc = DrawingClass("Correct UV Mode")
def unregister():
global dc
if dc:
dc.remove_handle()
dc = None
if __name__ == "__main__":
register()