Read new prefs: /home/a/.config/blender/2.78/config/userpref.blendWarning: TypeError('bpy_struct: item.attr = val: enum "ROLLLEFT" not found in (\'ANGLE\', \'LEFT\', \'RIGHT\')',)Warning: TypeError('bpy_struct: item.attr = val: enum "ROLLTRIGHT" not found in (\'ANGLE\', \'LEFT\', \'RIGHT\')',)Warning: TypeError('bpy_struct: item.attr = val: enum "ROLLLEFT" not found in (\'ANGLE\', \'LEFT\', \'RIGHT\')',)Warning: TypeError('bpy_struct: item.attr = val: enum "ROLLTRIGHT" not found in (\'ANGLE\', \'LEFT\', \'RIGHT\')',)
import bpy op = bpy.data.window_managers[0].keyconfigs[0].keymaps["3D View"].keymap_items["view3d.cursor3d"]class SimpleOperator(bpy.types.Operator): bl_idname = "wm.cursor3d_toggle" bl_label = "3D Cursor toggle" bop = bpy.props.BoolProperty() def execute(self, context): if op.active: self.report({'INFO'}, "3D Cursor UnLock") else: self.report({'INFO'}, "3D Cursor Lock") return {'FINISHED'} def invoke(self, context, event): op.active = not op.active return self.execute(context) class SimplePanel(bpy.types.Panel): bl_label = "3D Cursor" bl_space_type = "VIEW_3D" bl_region_type = "TOOL_PROPS" def draw(self, context): if op.active: self.layout.label("UnLock") else: self.layout.label("Lock") self.layout.operator("wm.cursor3d_toggle")bpy.utils.register_class(SimpleOperator)bpy.utils.register_module(__name__) bpy.ops.wm.cursor3d_toggle('INVOKE_DEFAULT')
import bpyops = [i for m in bpy.data.window_managers for k in m.keyconfigs for n in k.keymaps for i in n.keymap_items if i.idname=="view3d.cursor3d"]print(ops)op = ops[0]print(op.idname)class SimpleOperator(bpy.types.Operator): bl_idname = "wm.cursor3d_toggle" bl_label = "3D Cursor toggle" bop = bpy.props.BoolProperty() def execute(self, context): if op.active: self.report({'INFO'}, "3D Cursor UnLock") else: self.report({'INFO'}, "3D Cursor Lock") return {'FINISHED'} def invoke(self, context, event): op.active = not op.active return self.execute(context) class SimplePanel(bpy.types.Panel): bl_label = "3D Cursor" bl_space_type = "VIEW_3D" bl_region_type = "TOOL_PROPS" def draw(self, context): if op.active: self.layout.label("UnLock") else: self.layout.label("Lock") self.layout.operator("wm.cursor3d_toggle")bpy.utils.register_class(SimpleOperator)bpy.utils.register_module(__name__) bpy.ops.wm.cursor3d_toggle('INVOKE_DEFAULT')
import bpyops = [i for m in bpy.data.window_managers for k in m.keyconfigs for n in k.keymaps for i in n.keymap_items if i.idname=="view3d.cursor3d"]class SimpleOperator(bpy.types.Operator): bl_idname = "wm.cursor3d_toggle" bl_label = "3D Cursor toggle" bop = bpy.props.BoolProperty() def execute(self, context): if ops[0].active: self.report({'INFO'}, "3D Cursor UnLock") else: self.report({'INFO'}, "3D Cursor Lock") return {'FINISHED'} def invoke(self, context, event): for op in ops: op.active = not op.active return self.execute(context) class SimplePanel(bpy.types.Panel): bl_label = "3D Cursor" bl_space_type = "VIEW_3D" bl_region_type = "TOOL_PROPS" def draw(self, context): if ops[0].active: self.layout.label("UnLock") else: self.layout.label("Lock") self.layout.operator("wm.cursor3d_toggle")bpy.utils.register_class(SimpleOperator)bpy.utils.register_module(__name__) bpy.ops.wm.cursor3d_toggle('INVOKE_DEFAULT')