Clear All Logic

Ever find yourself needing to clear out mass amounts of logic? Here’s the solution! A simple addon that adds this button in the logic editor:


Copy-Paste this into Blender’s text editor and run, I’ll release an addon version soon.


import bpy


class RemoveAllLogicPlayer(bpy.types.Operator):
    bl_idname='wm.ok_removelogic'
    bl_label = 'Clear Logic'
    
    def execute(self, context):
        obj = bpy.context.active_object
        for i in obj.game.sensors:
            bpy.ops.logic.sensor_remove(sensor=i.name, object=obj.name)
        for i in obj.game.controllers:
            bpy.ops.logic.controller_remove(controller=i.name, object=obj.name)
        for i in obj.game.actuators:
            bpy.ops.logic.actuator_remove(actuator=i.name, object=obj.name)
            
        return({'FINISHED'})


class LOGIC_MT_logicbricks_clear(bpy.types.Header):
    bl_label = "Extra Options"
    bl_space_type = "LOGIC_EDITOR"
    bl_region_type = "UI"
    
    def draw(self, context):
        layout = self.layout
        
        layout.operator("wm.ok_removelogic")
        
def register():
    bpy.utils.register_class(LOGIC_MT_logicbricks_clear)
    bpy.utils.register_class(RemoveAllLogicPlayer)
def unregister():
    bpy.utils.unregister_class(LOGIC_MT_logicbricks_clear)
    bpy.utils.unregister_class(RemoveAllLogicPlayer)
    
if __name__ == "__main__":
    register()

Addon version:
Clear-Logic.zip (737 Bytes)

Nice add-on. I noticed you also can search (by pressing Spacebar in the Viewport) and type in ‘Clear Logic’. I’ll be using it for sure. Thanks.

This is nice, but Blender already has a built in way to do this. You select the object that you want logic removed from, then shift select an object with NO logic, go to Object > Game > Copy Logic Bricks.

Maybe yours is faster though?

I’d say it is faster, being only one button, and not needing any other objects.

Ya I guess, but what about the time it takes to download and install the addon? That’s a lot of time. I guess if I needed to clear logic a bunch of times then it would be worth it. Btw you can also just join the object that needs clearing to another object, that’s pretty fast.

It sure is faster, so thanks.