1
$\begingroup$

I write my Blender addon. And I need to redraw the panel and all panels below it in one of operator execute. So I can write

def redraw_panel():
    try:
        bpy.utils.unregister_class(PanelClass1)
        bpy.utils.unregister_class(PanelClass2)
        bpy.utils.unregister_class(PanelClass3)
    except:
        pass

    bpy.utils.register_class(PanelClass1)
    bpy.utils.register_class(PanelClass2)
    bpy.utils.register_class(PanelClass3)

But so I have problems adding new panels below (I need to write register and unregister for them in above function).

Is there any other way in Blender api to redraw UI and panels in Blender?

$\endgroup$
4
  • 3
    $\begingroup$ Suggest checking on if PanelClass1.is_registered: blender.stackexchange.com/a/202896/15543 Above pretty much depends on all being in sync. A tag redraw eg context.area.tag_redraw() is a common way to tag UI for redraw, although it is often not necessary blender.stackexchange.com/a/182852/15543 Assume you made some changes to panel class definition before calling op above? $\endgroup$ – batFINGER Jun 17 at 17:03
  • $\begingroup$ Thanks for your comment! Should I write tag context.area.tag_redraw() in my panel draw method? $\endgroup$ – Multifora Jun 17 at 17:21
  • 1
    $\begingroup$ Yes, that's the way to do it usually @Multifora $\endgroup$ – brockmann Jun 17 at 17:36
  • 1
    $\begingroup$ Thanks @brockmann $\endgroup$ – Multifora Jun 17 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.