I was wondering if it was possible to have a button on the toolbar that says " Clear Everything "
and have it run all these at the same time.
or atleast have it popup in the search menu when searching " Clear everything "
and have it be an addon aswell
bpy.ops.object.location_clear()
bpy.ops.object.rotation_clear()
bpy.ops.object.scale_clear()
Here you go:
import bpy
from mathutils import Matrix
class OBJECT_OT_clear_all(bpy.types.Operator):
"""Clear Location, Rotation and Scale"""
bl_idname = "object.clear_all"
bl_label = "Clear All"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
for ob in context.selected_editable_objects:
ob.matrix_world = Matrix.Identity(4)
return {'FINISHED'}
def draw_func(self, context):
layout = self.layout
layout.operator(OBJECT_OT_clear_all.bl_idname)
def register():
bpy.utils.register_module(__name__)
bpy.types.VIEW3D_MT_object_clear.append(draw_func)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.VIEW3D_MT_object_clear.remove(draw_func)
if __name__ == "__main__":
register()
# test call
bpy.ops.object.clear_all()
It’s available via Spacebar menu and 3D View > Object > Clear