Post #4876: Thank you for providing the script!
π Metadata
- Author: Pluglug
- Date: 2023-11-06 18:50:29
- Type:
answer - Quality Score: 8/10
- Reply to: post_04875
- Replies (1): post_04877
π·οΈ Tags
βοΈ Related PME Features
- 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()