MATLAB: How to get a handle to an area annotation in Simulink

simulink

I am working with Simulink models that have area annotations with customized description fields. What I would like to do is be able to click on one and use a command to get the annotation's handle. Then I could query its 'Description', 'Name', and so on for use with other scripts that will adjust formatting.
Is there a way to do this with annotations (which are not blocks)?

Best Answer

The following command returns a handle to the annotation if selected in the block diagram:
h = find_system(gcs,'FindAll', 'on', 'type','annotation','Selected','on');
You can then use the returned handle with the "get_param" function to query the annotation's description, etc.
get_param(h, 'Description')
For more on using the "find_system" function with annotations, refer to the following Documentation reference: https://www.mathworks.com/help/simulink/slref/find_system.html#bu322jn-1