Borrar filtros
Borrar filtros

Programmatically create annotation with hyperlink

9 visualizaciones (últimos 30 días)
Maximilian
Maximilian el 12 de Sept. de 2014
Respondida: Kent Schonert el 24 de Mayo de 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

Respuestas (2)

Kent Schonert
Kent Schonert el 24 de Mayo de 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 el 15 de Sept. de 2014
Editada: Rick Rosson el 15 de Sept. de 2014

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by