the goal was to simply have a bool value to change whether or not to show a custom panel with additional settings or no, it is modifier specific the first thought was simply register it on bpy.types.Modifier
but the BooleanProperty()
always fails to register and regardless of that blender doesn't allow class inheritance for it's classes
github link: https://github.com/Valery-AA/AlxOverHaul
video showing no errors: https://youtu.be/kjtJcAo2zvw
The Menu in question:
it shows a list of every modifier in all the selected objects and the check box next to the modifier name is the toggle options
prop()
with the little arrow pointing down is the sub-menu that is currently open just doesn't have any layout yet
The latest attempt consists of:
Property Group:
class Alx_PG_PropertyGroup_ModifierSettings(bpy.types.PropertyGroup):
""""""
object_name : bpy.props.StringProperty(name="", default="") #type:ignore
object_modifier : bpy.props.StringProperty(name="", default="") #type:ignore
show_options : bpy.props.BoolProperty(name="", default=False) #type:ignore
Registered as:
bpy.types.Object.alx_modifier_collection = bpy.props.CollectionProperty(type=AlxGeneralPanel.Alx_PG_PropertyGroup_ModifierSettings)
Used inside the draw_item
function of bpy.types.UIList
:
LayoutBox = layout.row().grid_flow(columns=1)
object_info = LayoutBox.row().box()
object_info.scale_y = 0.5
object_info.label(text=item.ObjectPointer.name)
modifier_slots = LayoutBox.row().grid_flow(columns=1)
for Collection_Modifier in item.ObjectPointer.alx_modifier_collection:
modifier_header = modifier_slots.row()
obj_modifier = item.ObjectPointer.modifiers.get(Collection_Modifier.object_modifier)
icon_name = bpy.types.Modifier.bl_rna.properties['type'].enum_items.get(obj_modifier.type).icon
modifier_delete_button : Alx_OT_Modifier_ManageOnSelected = modifier_header.operator(Alx_OT_Modifier_ManageOnSelected.bl_idname, icon="PANEL_CLOSE")
modifier_delete_button.object_pointer_reference = item.ObjectPointer.name
modifier_delete_button.create_modifier = False
modifier_delete_button.remove_modifier = True
modifier_delete_button.object_modifier_index = item.ObjectPointer.modifiers.find(Collection_Modifier.object_modifier)
modifier_header.prop(obj_modifier, "name", text="", icon=icon_name, emboss=True)
modifier_header.prop(Collection_Modifier, "show_options")
options_panel = modifier_slots.row().panel_prop(Collection_Modifier, "show_options")
options_layout : bpy.types.UILayout = options_panel[1]
modifier_header.prop(obj_modifier, "show_in_editmode", text="", emboss=True)
modifier_header.prop(obj_modifier, "show_viewport", text="", emboss=True)
modifier_header.prop(obj_modifier, "show_render", text="", emboss=True)
LayoutBox.row().separator(factor=2.0)
the issue with this attempt is that no matter what the checkbox won't go to True
or False
the property always resets instantly to the default value set inside the property group, it is clickable and it does change the value, just it instantly goes back to it's default
i would assume that the issue is sparked by the CollectionProperty
and PropertyGroup
but compared to the usual behaviour of throwing that the value can't be altered from a draw function context
or that the PointerProperty
value can't be change in the current context, there is simply nothing in the console whenever the button to open the menu is pressed, the button visually changes but it does nothing as if the bool was not altered at all
would there be any way to tell why the prop
to the bool property changes only visually and a possible fix?
RuntimeError: Error: Layout panels can not be used in this context
spam foroptions_panel = modifier_slots.row().panel_prop(Collection_Modifier, "show_options")
? $\endgroup$