When I try and toggle editmode from the console, it works. When I try and run it as a script I get:
AttributeError: ‘NoneType’ object has no attribute ‘ops’
This worked fine in 2.53, but now I’m completely stumped.
import bpy
class OBJECT_OT_testfunc(bpy.types.Operator):
bl_idname="test"
bl_label="test function"
@classmethod
def poll(self, context):
return (context.active_object != None)
def execute(self, context):
#making sure to be in object mode...
if context.mode != 'OBJECT':
bpy.ops.object.editmode_toggle()
#CODE OMITTED FOR TESTING
bpy.ops.object.editmode_toggle()
return {'FINISHED'}
class OBJECT_PT_testpanel(bpy.types.Panel):
bl_label = "Test Panel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("test")