Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/object.py
| Context not available. | |||||
| scene.objects.active = ob | scene.objects.active = ob | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| class ObjectClearHookOffset(bpy.types.Operator): | |||||
sergey: Use `Operator` instead of `bpy.types.Operator`. | |||||
| """Set hook object back to it's center""" | |||||
| bl_idname = "object.clearhookoffset" | |||||
Not Done Inline Actionsobject.clear_hook_offset is more proper name i guess. sergey: `object.clear_hook_offset` is more proper name i guess. | |||||
| bl_label = "Clear Hook Offset" | |||||
| bl_options = {'REGISTER', 'UNDO'} | |||||
| @classmethod | |||||
| def poll(cls, context): | |||||
| return (context.active_object is not None) | |||||
| def execute(self, context): | |||||
| active_object = context.active_object | |||||
| scene_objects = [o for o in context.scene.objects if o != active_object] | |||||
Not Done Inline ActionsDon't construct temp list, do if check in the loop instead. sergey: Don't construct temp list, do if check in the loop instead. | |||||
| for obj in scene_objects: | |||||
| for mod in obj.modifiers: | |||||
| if mod.type == 'HOOK': | |||||
Not Done Inline ActionsExtra space around operator. sergey: Extra space around operator. | |||||
| if mod.object == active_object: | |||||
| active_object.location = mod.center | |||||
| return {'FINISHED'} | |||||
| self.report({'WARNING'}, "Active Object is not a Hook") | |||||
| return {'FINISHED'} | |||||
| Context not available. | |||||
Use Operator instead of bpy.types.Operator.