Dynamic subpanels

Hi
I was wondering if it’s possible to dynamically draw subpanels based on the settings in the parent panel?

Look at the MeasureIt add-on included in Blender, menu panels change dynamically based upon what you are doing, this should give you some pointers.

You can also put conditional statements in the draw() method like:

If variable == 'Set'"
    col.prop(etc.......
else:
    Do something else...

You need a method to update the sub-panel, look in MeasureIt for how this is done.

Cheers, Clock.

Here’s a code snippet from MeasureIt Init file:

# --------------------------------------------------------------
# Register all operators and panels
# --------------------------------------------------------------

# Add-ons Preferences Update Panel

# Define Panel classes for updating
panels = (
        measureit_main.MEASUREIT_PT_Edit,
        measureit_main.MEASUREIT_PT_Main,
        measureit_main.MEASUREIT_PT_Conf,
        measureit_main.MEASUREIT_PT_Render,
        )


def update_panel(self, context):
    message = "MeasureIt: Updating Panel locations has failed"
    try:
        for panel in panels:
            if "bl_rna" in panel.__dict__:
                bpy.utils.unregister_class(panel)

        for panel in panels:
            panel.bl_category = context.preferences.addons[__name__].preferences.category
            bpy.utils.register_class(panel)

    except Exception as e:
        print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
        pass