Hello, I need some help again with my createion panel. Now I have come to adding modifier part, but whatever I do I cant get the “add modifier” button to show up. Heres my entire script so far:
import bpy
class LayoutDemoPanel(bpy.types.Panel):
"""Adds a panel in the right toolbar in the scene context for creating and edit objects"""
bl_label = "Create"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def draw(self, context):
layout = self.layout
scene = context.scene
def draw(self, context):
layout = self.layout
rd = context.scene.render
row = layout.row(align=True)
row.operator("render.render", text="Render", icon='RENDER_STILL')
#Add cube
row = layout.row()
props = row.operator("mesh.primitive_cube_add", text="Cube")
del row
#Add sphere
row = layout.row()
props = row.operator("mesh.primitive_uv_sphere_add", text="Sphere")
del row
#Add cynlinder
row = layout.row()
props = row.operator("mesh.primitive_cylinder_add", text="Cylinder")
del row
#Add light
row = layout.row()
layout.operator_enum("object.lamp_add", "type")
del row
#Add camera
row = layout.row()
props = row.operator("object.camera_add", text="Camera",)
del row
#Change to object or edit mode
layout.template_header_3D()
row = layout.row()
if obj:
mode = obj.mode
# Particle edit
if mode == 'PARTICLE_EDIT':
row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
#Add modifiers
row = layout.row()
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)
del row
def register():
bpy.utils.register_class(LayoutDemoPanel)
def unregister():
bpy.utils.unregister_class(LayoutDemoPanel)
if __name__ == "__main__":
register()