Python: Select specific parent object automatically on selection change? I have written an add-on which visualizes objects on a racing game track.

Each in-game object is an empty object in Blender with one or more children mesh objects being the visible model as seen in-game. The empty holds the game-relevant properties in a PropertyGroup which are visualized in a custom Panel.

Basically, the object hierarchy looks like this:


ItemBox &lt; Empty object holding custom properties the user is interested in


ItemBoxOuter &lt; A model the user selects
ItemBoxQuestionMark &lt; Just another model the user might also select

Start &lt; Another empty holding custom properties


StartLine &lt; Another model

and so on


Since empties are hard to select and often covered and encased by the models, I want to redirect the selection of such child mesh objects to the parent empty object. Is it possible to modify how the selection operator works here?

Background: At first I worked around this by letting the Panel which displays the PropertyGroup use the parent object to show its data. However, users began to move around the child model objects (having selected those), effectively keeping the in-game object at the same place as it uses the transform of the empty object.
I could solve this with an apphandler I registered to. I added a custom property to the model objects to recognize them in there.

def register():
    bpy.app.handlers.scene_update_post.append(addon.scene_update_post)

def unregister():
    bpy.app.handlers.scene_update_post.remove(addon.scene_update_post)

# ---- In the addon module ----

def scene_update_post(scene):
    ob = scene.objects.active
    if ob:
        # Redirect the selection of a model mesh object to the parent track object.
        if ob.is_model:
            scene.objects.active = ob.parent
            ob.parent.select = True
            ob.select = False


This works even when multi selecting objects!