0
$\begingroup$

Here's minimal example. When you click the 'X' mirror button in the 3D View header, the draw method is not called, so the panel is not updated. But draw is called when changing the mode. How can I get the draw to run when the property is changed?

enter image description here

import bpy

class VIEW3D_PT_test(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    bl_category = "Test" 
    bl_label = "Test"  

    def draw(self, context):
        if context.object.use_mesh_mirror_x:
            self.layout.label(text="Mirrored")

def register():
    bpy.utils.register_class(VIEW3D_PT_test)


def unregister():
    bpy.utils.unregister_class(VIEW3D_PT_test)

if __name__ == "__main__":
    register()

Edit

Steps to reproduce in Blender 3.3.3 and 3.3.20

  1. Remove the %appdata%\Blender Foundation\Blender\ directory (on Windows) to reset Blender to a clean state
  2. Open Blender
  3. (optionally arrange workspace to just the 3d view and text editor, show the tabs in the 3d view to capture just the relevant parts)
  4. Paste and run the script
  5. With the default cube selected, enter edit mode
  6. Click the 'X' mirror button on/off

Expected result: For each press of the 'X' mirror button, the 'Test' panel text will show/hide the text 'Mirrored'

Actual result: The 'Mirrored' text does not show or hide until performing some edit action on the mesh (some other actions will also trigger a panel draw call, editing the mesh is just one example)

Screen capture in action

enter image description here

This issue exists in Blender 3.3.20, however this behaves as expected in 4.0.2 like the screen capture @harry-mckenzie shared. So maybe it's a bug?

$\endgroup$
4
  • $\begingroup$ what are you trying to achieve? explain more $\endgroup$
    – Karan
    Commented Jul 7 at 11:53
  • $\begingroup$ Hello and welcome. It is not clear what you mean. When I tested it works as seen in this gif i.sstatic.net/MBqmKlvp.gif you can see that the draw method is always called and draws the text Mirrored when X is clicked $\endgroup$
    – Harry McKenzie
    Commented Jul 7 at 13:09
  • $\begingroup$ @HarryMcKenzie thank you for the comment. Updated the question. Maybe it's a bug? $\endgroup$
    – m35
    Commented Jul 7 at 18:05
  • $\begingroup$ @m35 Thank you for sharing more information on this. Yes it looks like it's a bug and unfortunately bugs are off-topic. This is Q&A site run by volunteers, we are not programmers nor in any way associated with the Blender Foundation, decision making nor development process of the software. For bug reports please see our Guide on How to Report a Bug $\endgroup$
    – Harry McKenzie
    Commented Jul 8 at 2:17

0

Browse other questions tagged .