0

Is it possible to add a sub panel into a redo panel? If so, any kind of example, tutorial, link etc would be highly appreciated.

Simos Sigma
  • 413
  • 3
  • 11
  • 2
    Even if you think that's a simple question, it's always harder getting into it for us without any sketch or example code. There are a lot possibilities as well as limitations as you might know by now. – brockmann Oct 29 '20 at 09:05
  • AFAIK the answer is no. The "redo panel" is an operator (bpy.types.Operator), a subpanel requires a parent that is a panel (bpy.types.Panel) Can emulate a subpanel with conditionals in draw method, but it's not a real subpanel Way back commented here https://blender.stackexchange.com/questions/196824/how-can-i-make-a-dialog-window-make-changes-in-real-time#comment330059_196824 that perhaps using an operator approach for prefs was flawed and to consider making a prop group for this. Other issues have popped up re using the operator approach ie using the value of one in another – batFINGER Oct 29 '20 at 09:34
  • and here once again, another issue. My feeling is trying to use an operator redo panel for everything kinda makes you a A one trick pony down a rabbit hole Here is a recent answer re using the panel popover which in assoc with setting up pref property group would be perfect preferences https://blender.stackexchange.com/questions/197265/blender-python-api-custom-gui/197283#197283 – batFINGER Oct 29 '20 at 09:41
  • @batFINGER in other words your advice is not to use redo panel when have to make something like this? And that it would be better to work at the n panel for example? – Simos Sigma Oct 29 '20 at 10:07
  • The linked image never loads for me. Advice is to consider it. IIRC I have mentioned also to look at code of add sapling addon that (last I looked) uses one monster redo panel. (All options available in one operator) A lot depends on what your addon does. Recommend finding an addon that does the same / similar and investigate the code. – batFINGER Oct 29 '20 at 10:33
  • https://drive.google.com/file/d/1ztSSU84ciSbXSYq-rCzl1XtXvCPgm7Se/view – Simos Sigma Oct 29 '20 at 10:44
  • @batFINGER there is no monster redo panel anymore (depending on what do you mean by monster). I have "break" the whole thing to parts. Properties also have "broke" into property groups. Generally I changed everything according to your advises and your examples like this one ( https://blender.stackexchange.com/questions/183773/trying-to-make-a-menu-using-multiple-modules/183817#183817 ). I just wanted to add sub panels into redo panels for decorative purposes. Anyway, I made it with labels, arrow icons and some boolean so to emulate the fold and unfold actions. – Simos Sigma Oct 30 '20 at 08:22
  • @brockmann excuse me that I didn't edit my question so to add more details as you asked me to do. I didn't ignore you. After your comment I started to edit my question, but then I got batFINGER's comment who wrote that isn't possible, so I stopped the update of my question. – Simos Sigma Oct 30 '20 at 08:35

1 Answers1

0

I can't imagine why my question has been downvoted, but anyway...

I wanted to add a sub panel into a redo panel, mainly for decorative purposes. As batFINGER said, this can't be done. So I made a fake sub panel with a label, an icon and a boolean.

Here is a code example of how I made it, if anyone wants to do something similar:

import bpy

class MYADDON_properties(bpy.types.PropertyGroup): fold : bpy.props.BoolProperty(name="fold", default=0)

class MYADDON_PT_main_panel(bpy.types.Panel): bl_idname = "myaddon.main_panel" bl_label = "Fake Sub Panel for Redo Panel" bl_space_type = "VIEW_3D" bl_region_type = "UI" bl_category = "MYADDON"

def draw(self, context):
    layout = self.layout
    row = layout.row()
    row.operator("MYADDON.operator")

class MYADDON_OT_operator(bpy.types.Operator): bl_idname = "myaddon.operator" bl_label = "Operator" bl_description = "Operator" bl_options = {'REGISTER','UNDO'}

def draw(self, context):
    my_props = context.window_manager.myaddon_properties

    layout = self.layout
    row = layout.row()
    row.split()
    row.alignment = 'RIGHT'
    if my_props.fold:
        row.operator("MYADDON.unfold", text="", emboss=False, icon='DISCLOSURE_TRI_RIGHT')
    else:
        row.operator("MYADDON.fold", text="", emboss=False, icon='DISCLOSURE_TRI_DOWN')
    row.alignment = 'LEFT'
    row.label(text="Fake Sub Panel")
    if not my_props.fold:
        col = layout.column(align=True)
        col.label(text="Label #1")
        col.label(text="Label #2")
        col.label(text="Label #3")

def execute(self, context):
    return {"FINISHED"}

class MYADDON_OT_fold(bpy.types.Operator): bl_idname = "myaddon.fold" bl_label = "" bl_description = ""

def execute(self, context):
    my_props = context.window_manager.myaddon_properties
    my_props.fold = True
    return {"FINISHED"}

class MYADDON_OT_unfold(bpy.types.Operator): bl_idname = "myaddon.unfold" bl_label = "" bl_description = ""

def execute(self, context):
    my_props = context.window_manager.myaddon_properties
    my_props.fold = False
    return {"FINISHED"}

classes = ( MYADDON_properties, MYADDON_OT_operator, MYADDON_OT_fold, MYADDON_OT_unfold, MYADDON_PT_main_panel, )

def register(): from bpy.utils import register_class for cls in classes: bpy.utils.register_class(cls) bpy.types.WindowManager.myaddon_properties = bpy.props.PointerProperty(type = MYADDON_properties)

def unregister(): from bpy.utils import unregister_class for cls in classes: unregister_class(cls) del bpy.types.WindowManager.myaddon_properties

If someone has any kind of corrections or suggestions...

Simos Sigma
  • 413
  • 3
  • 11