Access model viewmarks and notes programmatically

5 ビュー (過去 30 日間)
Alexander Boll
Alexander Boll 2022 年 6 月 3 日
回答済み: Satwik 2025 年 2 月 17 日
I would like to access all of a model's viewmarks and notes in an automatic fashion.
For this I would need two pointers:
  1. How to get a list of all viewmarks+notes associated to a model. (find_system seems not to output them)
  2. A list of the parameters of viewmarks (name, associated subsystem, coordinates ...?) and notes (note texts ...) so as to access their content.
If you can only help with one of the two, it would still help :)

回答 (1 件)

Satwik
Satwik 2025 年 2 月 17 日
I believe that viewmarks and notes in Simulink are part of the model annotations. The 'get_param' function along with the 'find_system' function can be used to access the annotation details from the model.
Here is a possible approach to achieve this:
% Load the model
load_system('your_model_name');
% Get all annotations in the model
annotations = find_system('your_model_name', 'FindAll', 'on', 'Type', 'annotation');
% Iterate over annotations to get details
for i = 1:length(annotations)
annotation = annotations(i);
text = get_param(annotation, 'Text');
position = get_param(annotation, 'Position');
% Display or process the annotation details
fprintf('Annotation %d: %s at position [%d, %d]\n', i, text, position(1), position(2));
end
I hope this helps!

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by