Filter löschen
Filter löschen

Programmatically create annotation with hyperlink

9 Ansichten (letzte 30 Tage)
Maximilian
Maximilian am 12 Sep. 2014
Beantwortet: Kent Schonert am 24 Mai 2022
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

Antworten (2)

Kent Schonert
Kent Schonert am 24 Mai 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'
;

Rick Rosson
Rick Rosson am 15 Sep. 2014
Bearbeitet: Rick Rosson am 15 Sep. 2014

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by