Hello to everyone!
This is my first post on this forum.
version: Blender 2.62
I am creating an Addon.
I created two operators (buttons) on Object Tools Panel:
My operator classes are in different file in the same directory with ini.py
In init.py file I have something similar to this:
from . import *
class VIEW3D_PT_SomeClass_objectmode(bpy.types.Panel):
bl_label = "My Class"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = 'objectmode'
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
row = col.row()
row.operator('mesh.operator_01_add', text='Add Object1')
row.operator('mesh.operator_02_add', text='Add Object2')
class INFO_MT_mesh_SomeClass_add(bpy.types.Menu):
bl_label = "My Class"
def draw(self, context):
layout = self.layout
layout.operator('mesh.operator_01_add', text='Add Object1')
layout.operator('mesh.operator_02_add', text='Add Object2')
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
My problem is next:
Menu part is workig correctly but Panel part is doing some strange things which I can not understand.
When I launch Blender, my Addon is loaded and Panel is showing properly in Object Tools panel and Menu as well in its proper place.
When I press the buttons ‘Add Object1’ or ‘Add Object2’ it adds properly the corresponding object in the scene.
However if I delete my object in the scene my Panel disapears, but I can still use menu.
If I add any object (Plane, Cube, Lamp, etc.) or my own object or just select some object, it pops back again.
What I figured out is that when an object is deleted in the scene, then there is no more active object in that scene.
That is the moment when I loose my Panel. As soon there is an active object in the scene my panel appeares again and operators on Panel works correctly.
How can I achieve that my Panel sits in place like other built in operators on Object Tools Panel regardless there is an active object or not?
Or what could cause this behavior?
Thanks in advance.
robi