Adding "add lamp" button dont work

Couldnt find a better title so here it goes:

Im writing my own little create panel, so I can have the createtools to the right instead of having to have
the left toolbar open all the time. YES, I know I can just go to add>lamp or spacebar>add>lamp, but Id like
to eliminate those and just have everything in one place. Im completly new to scripting and have no what so
ever experience so this is my first time trying to actually write a script (Thanks CG Cookie).

Heres the error I get:

IndentationError: expected an indented block

Layout.operator_enum(“object.lamp.add”, “type”)

Heres my script:

import bpy

class LayoutDemoPanel(bpy.types.Panel):
“”“Creates a Panel in the scene context of the properties editor”""
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

    # Create a simple row.
    layout.label(text="Create:")

    #Buttons for adding models


    #Add a cube 
    row = layout.row()
    props = row.operator("mesh.primitive_cube_add", text="Cube")
    
    del row
    
    #Add a sphere
    row = layout.row()
    props = row.operator("mesh.primitive_uv_sphere_add", text="Sphere")
    
    del row
    
    
    #Add a cynlinder
    row = layout.row()
    props = row.operator("mesh.primitive_cylinder_add", text="Cylinder")
    
    del row
    
    #Add light 
    row = layout.row()
    
    @staticmethod
    def draw_add_lamp(layout):
    layout.operator_enum("object.lamp_add", "type")
    
    del row

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

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

if name == “main”:
register()

Hope someone have time to help.

I think the first thing to do is to do what’s suggested in the message : indent correctly like bellow.

The script will run without warning.


import bpy




class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    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


        # Create a simple row.
        layout.label(text="Create:")


        #Buttons for adding models




        #Add a cube 
        row = layout.row()
        props = row.operator("mesh.primitive_cube_add", text="Cube")


        del row


        #Add a sphere
        row = layout.row()
        props = row.operator("mesh.primitive_uv_sphere_add", text="Sphere")


        del row




        #Add a cynlinder
        row = layout.row()
        props = row.operator("mesh.primitive_cylinder_add", text="Cylinder")


        del row


        #Add light 
        row = layout.row()


    @staticmethod
    def draw_add_lamp(layout):
        layout.operator_enum("object.lamp_add", "type")


        del row


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


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


if __name__ == "__main__":
    register()



Thanks for your help. I didnt get any warnings now, but I cant see a button for adding a lamp. What more do I miss?
I tried

@staticmethod
def draw_add_lamp(layout):
props = row.operator(“object.lamp_add”, “type”)

But that didnt work.

That’s true, but I don’t know for this other problem for now as I’m not experience with blender api enough

Ok, try that instead ?



        #Add light 
        row = layout.row()
        props=layout.operator_enum("object.lamp_add", "type")
        del row

Thanks alot, that worked :slight_smile: Heres my createpanel as it looks now: