Hi all,
I’m trying to write my first operator. I want to generate objects according to some rules. It works on the first execute, but as soon as I change a parameter, it crashes.
I narrowed down the crash to this minimal code:
class QuickGenOperator(bpy.types.Operator):
bl_idname = "quickgen.operator"
bl_label = "Quick Gen"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
m_ref_object = None
m_size_jitter = bpy.props.FloatProperty(
name="Size Jitter",
default=0.1,
soft_min=0,
soft_max=10)
def invoke(self, context, event):
self.m_ref_object = context.scene.objects["Cylinder"]
return self.execute(context)
def execute(self, context):
newobj = self.m_ref_object.copy()
context.scene.objects.link(newobj)
return {'FINISHED'}
def draw(self, context):
layout = self.layout
col = layout.column()
col.prop(self, "m_size_jitter")
#----------------------------------------------------------
class QuickGenPanel(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_idname = "quickgen.panel"
bl_label = "Quick Gen"
@classmethod
def poll(cls, context):
return (context.object is not None)
def draw(self, context):
self.layout.operator("quickgen.operator")
#----------------------------------------------------------
def register():
bpy.utils.register_class(QuickGenOperator)
bpy.utils.register_class(QuickGenPanel)
def unregister():
bpy.utils.unregister_class(QuickGenOperator)
bpy.utils.unregister_class(QuickGenPanel)
When I first call the operator, invoke() and execute() are called, and it works fine (I can see the newly created object in the scene tree). If I tweak the m_size_jitter property slider, it calls execute() again, and Blender crashes 100%. Any idea why ?
I’m using 2.63