0
$\begingroup$

I want to display the modifier panel in the Npanel,

I have achieved the panel like this, but I cant't display the added modifiers:

enter image description here

This is my code:

import bpy
from bpy.types import Panel

from bl_ui.properties_data_modifier import DATA_PT_modifiers

class HelloWorldPanelA(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_helloA"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    
    bl_category= 'NewTab'
    
    
    def draw(self, context):
        mp = DATA_PT_modifiers(context)
        layout = self.layout
        ob = context.object
        row = layout.row()        
        layout.operator_menu_enum("object.modifier_add", "type")
        layout.template_modifiers()
        
            


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


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


if __name__ == "__main__":
    register()

if I add a "Bevel modifier", it will got an error "Panel type 'MOD_PT_Bevel' not found."

So how to display the added modifiers? Thank you very much

$\endgroup$
2

1 Answer 1

-1
$\begingroup$

I hope it helps you

class PanelName(Panel):
"""Creates a Panel in the Object properties window"""
bl_label = ""
bl_idname = "OBJECT_PT_name"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_options = {'HIDE_HEADER'}

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

    obj = context.object
    row = layout.row()
    row.operator_menu_enum("object.modifier_add", "type")
    row = layout.row(align=True)
    if obj.modifiers:
        icon = [i for i in obj.modifiers.active.bl_rna.properties['type'].bl_rna.properties['icon'].enum_items.keys() if obj.modifiers.active.type in i][0]
        row.enabled =  obj.modifiers.active.is_active
        row.operator("object.modifier_set_active", text="", icon=icon)
        row.prop(obj.modifiers.active, "name", text="")
        row.prop(obj.modifiers.active, "show_in_editmode", text="")
        row.prop(obj.modifiers.active, "show_viewport", text="")
        row.prop(obj.modifiers.active, "show_render", text="")
        row.prop(obj.modifiers.active, "show_on_cage", text="")
        exclud_props = ['name', 'show_in_editmode', 'show_viewport', 'show_render', 'show_on_cage', 'rna_type', 'type', 'is_active', 'use_apply_on_spline', 'show_expanded', 'is_override_data']
        for p in obj.modifiers.active.bl_rna.properties.keys():
            if not p in exclud_props:
                if p == 'subdivision_type':
                    row = layout.row()
                    for v in obj.modifiers.active.bl_rna.properties[p].enum_items.keys():
                        row.prop_enum(obj.modifiers.active, p, value=v)
                else:
                    layout.prop(obj.modifiers.active, p)

it works but only show the active one

$\endgroup$
1
  • $\begingroup$ Thank you so much! $\endgroup$
    – liuran
    Nov 23 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .