A small change in code. Help!

First, if ba manager thinks its a double post please delete the other in modeling section ok, it suits better here!!!

I got the code from here:
:anchor: T50721 BVH overlap() failing to detect intersection due to bmesh rotation not updating until script ends (blender.org)

Two small changes in code and its finished:

Number one is make obj2 to be the selected and obj1 the ACTIVE selected object so there is no need to rename objects hundreds of times to suit the code.

ob1 = bpy.data.objects[‘Plane’]
ob2 = bpy.data.objects[‘Plane.001’]

Number two is a shortcut for the 3d viewport, so there is no need to have the mouse pointer over the text window to press Alt+P to run the script.

Please help, with the script as it is now is taking so much longer the repetitive work.

My regards!

Selecting two objects can be done with the following function. The second parameter tells the function to either deselect all other objects before selecting the object, or to leave whatever is selected as it is.

# Has an option to either deselect all, or keep other things selected.
def obyname(name, deselectall=True):
    for ob in bpy.context.window.scene.objects:
        if(deselectall):
            ob.select_set(False)
            for obj in bpy.context.selected_objects:
                obj.select_set(False)
        if(ob.name==name):
            bpy.context.view_layer.objects.active = ob
            ob = bpy.context.active_object
            ob.select_set(True)
    return ob

This is from my fifth tutorial on my website. https://www.archeuslore.com/blender/blender.html