2
$\begingroup$
import bpy 

from bpy.types import Menu, Panel, UIList

class View3DPanel(): 
  bl_space_type = 'VIEW_3D' 
  bl_region_type = 'TOOLS'


class OpenStudioAddRigPanel(View3DPanel, Panel): 
 bl_label = "Test" 
 bl_context = "objectmode" 
 bl_category = "Test" 


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 register(): bpy.utils.register_module(__name__)
def unregister(): bpy.utils.unregister_module(__name__)
if __name__ == "__main__": register()
print("Add Rig loaded")

So I try to learn how I could move the modifier stack into the tool shelve so I can work full screen without the need of the button menu.

I am totaly new at UI scripting and scripting in general with Blender, so I am looking for some guidance and tips what to do. I managed to make some modifier related stuff appear in the tool shelve but it does not list all added modifiers and such.

enter image description here

So I looked into: "properties_data_modifier.py" This defines for example a boolean modifier operation but I fail to see how I could also get this running in the tool shelve. Sad me ;)

def BOOLEAN(self, layout, ob, md):
    split = layout.split()

    col = split.column()
    col.label(text="Operation:")
    col.prop(md, "operation", text="")

    col = split.column()
    col.label(text="Object:")
    col.prop(md, "object", text="")

So to sum it up: what I try to look for is the ability to list all added modifiers in the 3D view port tool panel and in addition enable you to edit them.

I did a quick hack and edited the modifier py script and it all can be displayed in the tool panel - so technically this is possible. Can somebody tell me how one could include this as a class in a new script? enter image description here

$\endgroup$
5
$\begingroup$

The panel displaying the modifiers includes methods with names matching every modifier type that are used to display the properties of the matching modifier, getattr() is used to find the matching method based on the type of modifier in the objects modifier list.

While inheriting the modifiers panel directly causes issues, you can create a local instance of the panel and make use of the methods it contains.

import bpy
from bl_ui.properties_data_modifier import DATA_PT_modifiers

class myModifiersPanel(bpy.types.Panel):
    bl_label = "Object Modifiers"
    bl_idname = "OBJECT_PT_mymodifiers"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Modifiers"

    def draw(self, context):
        mp = DATA_PT_modifiers(context)
        layout = self.layout
        ob = context.object
        row = layout.row()

        if not ob.modifiers:
            row.label('No modifiers')
        else:
            for md in ob.modifiers:
                box = layout.template_modifier(md)
                if box:
                    getattr(mp, md.type)(box, ob, md)

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

def unregister():
    bpy.utils.unregister_class(myModifiersPanel)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Works like a charm! Sad that I was not able to figure thus out myself as this looks very logical. grrrr $\endgroup$ – Claas Kuhnen Jan 3 '16 at 19:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.