Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/templates_py/operator_mesh_uv.py
| Show All 27 Lines | class UvOperator(bpy.types.Operator): | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| obj = context.active_object | obj = context.active_object | ||||
| return obj and obj.type == 'MESH' and obj.mode == 'EDIT' | return obj and obj.type == 'MESH' and obj.mode == 'EDIT' | ||||
| def execute(self, context): | def execute(self, context): | ||||
| main(context) | main(context) | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| def menu_func(self, context): | |||||
| self.layout.operator(UvOperator.bl_idname, text = "Simple UV Operator") | |||||
| def register(): | def register(): | ||||
| bpy.utils.register_class(UvOperator) | bpy.utils.register_class(UvOperator) | ||||
| bpy.types.IMAGE_MT_uvs.append(menu_func) | |||||
| def unregister(): | def unregister(): | ||||
| bpy.utils.unregister_class(UvOperator) | bpy.utils.unregister_class(UvOperator) | ||||
| bpy.types.IMAGE_MT_uvs.remove(menu_func) | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| register() | register() | ||||
| # test call | # test call | ||||
| bpy.ops.uv.simple_operator() | bpy.ops.uv.simple_operator() | ||||