how to show boolean modifer menu from Modifier menu inside 3DView Tool shelf

I would like to work in in 3D view non stop and be able to add and modify modifiers I added to an object in 3D view space right inside the tool shelve.

I am able to add the modifier button but thats all.

I am pretty new to coding in Blender.

## Modifiers
row = layout.row(align=True)
row.operator_menu_enum(“object.modifier_add”, “type”)

this works, but when I add the rest it fails

for md in ob.modifiers:
box = layout.template_modifier(md)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, md.type)(box, ob, md)

Would you like a script that lays out the entire modifier panel and properties in the toolbar?

This is a straight copy from the operator drop down list.
You can see it yourself by doing right click on the item and show source code.

layout.operator_menu_enum("object.modifier_add", "type")

A side note: There are about 5 (more or less) super useful modifiers in Blender
but all the others are not so essential on a constant need (e.g. Vertex Weight Proximity,
Wave, Displace, Hook).

In the example below I used simple operator buttons, and also as a bonus, giving
the most essential properties of the modifier for editing.


import bpy


class LayoutDemoPanel(bpy.types.Panel):   
    bl_label = "Hello from Tools"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    
    def draw(self, context):
        layout = self.layout
        
        modifier = self.getSubsurfModifier(context.object)
        if modifier == None:
            layout.label("Add Subsurface Modifier")
            op = layout.operator("object.modifier_add")
            op.type="SUBSURF"
        else:
            layout.label("Edit Subsurface Modifier")
            layout.prop(modifier, "levels")
    
    def getSubsurfModifier(self, object):
        if len(object.modifiers) == 0:
            return None
        
        for i in object.modifiers:
            if i.type == "SUBSURF":
                return i
        
        return None
        
try:
    bpy.utils.unregister_class(LayoutDemoPanel)
except:
    pass


bpy.utils.register_class(LayoutDemoPanel)



At stackexhange Zeffii posted this:

It recreates the modifiers in a panel in the tool shelve



import bpy
from bpy.types import Menu, Panel, UIList
from bl_ui.properties_data_modifier import DATA_PT_modifiers as PT_MOD

@classmethod
def poll(cls, context):
return (context.object is not None)

def draw(self, context):
layout = self.layout

ob = context.object

layout.operator_menu_enum("object.modifier_add", "type")

for md in ob.modifiers:
    box = layout.template_modifier(md)
    if box:
        # match enum type to our functions, avoids a lookup table.
        getattr(self, md.type)(box, ob, md)

def make_panel(name, poll, draw, funcs):
overwrites = {
“bl_space_type”: “VIEW_3D”,
“bl_region_type”: “TOOLS”,
“bl_label”: “Test”,
“bl_context”: “objectmode”,
“bl_category”: “Test”,
“poll”: poll,
“draw”: draw
}

for f in dir(funcs):
    if f.isupper():
        overwrites[f] = getattr(funcs, f)

return type(name, (Panel,), overwrites)

RigPanel = make_panel(“OpenStudioAddRigPanel”, poll, draw, funcs=PT_MOD)

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

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

if name == “main”:
register()
print(“Add Rig loaded”)