I want to trigger a function when any mesh vertex is selected. After alot of research, using msgbus.subscribe_rna seems to be the way to go, unfortunately even though i can use it to trigger a function when say, objects are selected, when i try the same for changes in vertex propterties it has no effect.
import bpy
handle = object()
#subscribe_to = bpy.types.MeshVertex, "select" # Doesn't do anything
subscribe_to = bpy.context.object.data.vertices[0].path_resolve("select", False) #Doesn't do anything
#subscribe_to = bpy.types.LayerObjects, "active" # Triggers when an object is made active
#subscribe_to = bpy.types.Object, "location" # Triggers when an objects location is changed in N panel
def notify_test(*args):
print("Notify changed!", args)
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=handle,
args=(),
notify=notify_test,
)
bpy.msgbus.publish_rna(key=subscribe_to)
Mesh.vertices
has to be done in object mode. Running code above withMeshVertex.select
triggers the message by running>>> C.object.data.vertices[0].select = False
in console in object mode. $\endgroup$