Post #4876: Thank you for providing the script!

πŸ“‹ Metadata

🏷️ Tags

scripting intermediate solved

  • Python Scripting
  • Autorun Scripts
  • Pie Menu Editor

πŸ’¬ Content

Thank you for providing the script!
I believe it’s quite a practical script. How about performing the drawing condition check within the draw_callback_px function? If the conditions are simple, it should have minimal impact on performance.
You can have the script run every time Blender starts by saving it in the autorun of the pie_menu_editor at the following path:
C:\Users\YourName\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\pie_menu_editor\scripts\autorun

Here is the script for your reference:

import bpy
import blf

draw_handler = None

def draw_callback_px(self, context):
    if context.mode != 'EDIT_MESH':
        return
    
    tool_settings = context.tool_settings
    if getattr(tool_settings, "use_transform_correct_face_attributes", False):
        font_id = 0
        blf.position(font_id, 50, 50, 0)
        blf.size(font_id, 50)
        blf.color(font_id, 1.0, 0.5, 0.0, 1.0)  # Orange color
        blf.draw(font_id, "CFA On")


def register():
    global draw_handler
    draw_handler = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, (None, bpy.context), 'WINDOW', 'POST_PIXEL')

def unregister():
    global draw_handler
    bpy.types.SpaceView3D.draw_handler_remove(draw_handler, 'WINDOW')
    draw_handler = None

if __name__ == "__main__":
    register()

Correction:
If you wish to add it to PME’s autorun, please make the following modification.
Before correction:

if __name__ == "__main__":
    register()

After correction:

register()

πŸ”— View on Blender Artists