How can I find the selected metaball elements in Edit mode with Python? If you have an active object you can find the currently selected sub elements; e. g. in an active mesh you can find the selected vertices while looping over them and check the property bpy.context.active_object.data.vertices[i].select.

In an active armature you can achieve the same with bpy.context.active_object.data.bones[i].select_head (or select_tail).

But for metaballs I cannot find a property
bpy.context.active_object.data.elements[i].select or something like that. How can I retrieve the selected element(s) in a metaball object?

Background: In Edit mode you can add additional metaballs to a metaball object. I want to move the selected elements via Python.
That one's not easy. I checked the Outliner to get the path to the elements:



I haven't been able to find the full selection yet, but the active ball can be found and moved:

import bpy
bpy.data.metaballs["Mball"].elements[2].co.x += 0.1
bpy.context.active_object.data.elements.active.co.x += 0.1
bpy.data.metaballs["Mball"].elements.active.co.x += 0.1


I hope somebody can prove me wrong but it might not be exposed to the API. Metaballs don't get a lot of limelight. In which case it would be worth to find the right dev to implement it.

Only workaround I can see is to keep the metaballs separated, select them in object mode, manipulate them there(they still merge anyway) and use that selection and join them afterwards. Depends on how many you need to move.