Panel and buttons not appearing when creating addon.

I’m making a test addon just to get through all the steps of making an addon. I slightly modified the Operator Simple template to turn the active object in Z. And I modified UI Panel Simple to activate the turning on when a button is pressed. I put all the code into one .py file. When I read the file into the text editor and run the script, everything works okay. I get a new section in the Object panel, properly labeled and with the button. The button activates the rotation operator when pressed.

And I’ve gotten so that I can pull in the resulting py file into Blender using the User Preferences window. But I don’t see an added section in the Objects panel. I’ve tried looking at other py files, but haven’t found anything that gives me a clue as to what I am doing wrong. Any ideas?

Thanks.



# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****

# ------ ------
bl_info = {
    'name': 'test_addon',
    'author': '',
    'version': (0, 0, 0),
    'blender': (2, 6, 4),
    'api': 51291,
    'location': 'Properties > Object',
    'description': '',
    'warning': '',
    'wiki_url': '',
    'tracker_url': '',
    'category': 'Mesh' }

import bpy

def main(context):
    for ob in context.scene.objects:
        print(ob)


class simple_panel(bpy.types.Panel):

    """ tooltip """
    bl_label = "Panel name"
    bl_idname = "panel_id"

    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'

    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        layout.operator("object.operator_id")


class simple_operator(bpy.types.Operator):

    """ tooltip """
    bl_label = "Operator name"
    bl_idname = "object.operator_id"

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

    def execute(self, context):
        main(context)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(simple_panel)
    bpy.utils.register_class(simple_operator)

def unregister():
    bpy.utils.unregister_class(simple_panel)
    bpy.utils.unregister_class(simple_operator)

if __name__ == "__main__":
    register()


Thank you. The key change was that I had just copied and pasted both templates. So the def register(): and def unregister(): for both classes were seperate. When I condensed them as you did, and put both the simple_panel and simple_operator calls together it worked. :smiley: