Programmatically create annotation with hyperlink

5 views (last 30 days)
Hello,
I have a model in which I would like to include a hyperlink to an excel file that contains more information about the model. The model and excel file are contained within the same Simulink project however I would like to be able to share the project with someone else, but maintain that hyperlink regardless of where they put the project file.
In my project open script I am getting the root directory of the project using ProjectRootDir = fileparts(mfilename('fullpath'));
and I know I can create an annotation programmatically using the methods described here: http://www.mathworks.com/help/simulink/ug/create-an-annotation-programmatically.html
But no where do I see a parameter to enable a hyperlink and create it using a Matlab variable. Is there another way to implement this?
Thanks!
Max

Answers (2)

Rick Rosson
Rick Rosson on 15 Sep 2014
Edited: Rick Rosson on 15 Sep 2014

Kent Schonert
Kent Schonert on 24 May 2022
I found a solution by looking at the properties of a GUI created hyperlink annotation.
hyperlink = 'www.google.com';
displayText = 'Google';
textValue = [...
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' char(13)...
'<html><head><meta name="qrichtext" content="1" /><style type="text/css">' char(13) ...
'p, li { white-space: pre-wrap; }' char(13) ...
'</style></head><body style=" font-family:''Arial''; font-size:10px; font-weight:400; font-style:normal;">' char(13) ...
'<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="' hyperlink '"><span style=" text-decoration: underline; color:#0000ff;">' displayText '</span></a></p></body></html>'];
a = Simulink.Annotation(gcs,textValue);
a.Interpreter = 'rich'
;

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!