Programmatically capturing screenshots of Simulink blocks and dialogs

72 vues (au cours des 30 derniers jours)
Carl Banks
Carl Banks le 1 Août 2018
This is a shot in the dark, but does anyone know of a convenient built-in way to programmatically create screen captures of Simulink blocks and dialogs? This is for documentation purposes. We'd like to show an image of the block and the dialog in the documents but we don't want to manually screencap the block and dialog of upwards of a hundred blocks.
  3 commentaires
Carl Banks
Carl Banks le 9 Oct 2018
Modifié(e) : Carl Banks le 9 Oct 2018
I ended up doing this, and using some functions from image processing toolbox to help crop the screenshots. Thanks for the suggestions. If you repost this as an answer I'll accept it (if you care about that kind of thing).
Matthias Liermann
Matthias Liermann le 22 Juin 2020
Hi Carl, I am trying to do the same. I would like to programmatically take a screenshot of blocks in a model. How were you able to get the position of the block on the screen to take a screenshot of? The command
get_param(gcb,'position')
only gets you the position of the block relative to a model window reference. However, I couldn't figure out how to get the origin of this model window reference on the screen.

Connectez-vous pour commenter.

Réponse acceptée

Greg
Greg le 10 Oct 2018
You can import java packages into MATLAB, one of them (java.awt.* ??) includes the ability to take screenshots. I'm assuming there's an open or edit equivalent to launch each block, then use the java to capture screen.

Plus de réponses (2)

Fangjun Jiang
Fangjun Jiang le 1 Août 2018
You might want to try Simulink "Web View". In the Simulink model, click menu File, Export model to, Web...
A html document is created. You can browse the hierarchy of the model just like in Simulink. Block dialog is not shown but block parameters are shown whenever you click a block. This is great for documentation purpose.
Alternatively, try menu File, Print, to a PDF file.

Dave
Dave le 9 Avr 2019
Simulink has this built in:
% Open a model
f14
% Choose name of model to be screenshot
ModelName = 'f14'
% Save the screenshot to a file, named the model name...
print(['-s',ModelName],'-djpeg',[ModelName,'.jpg'])
You can choose: JPG, BMP, PNG etc
More here: print
  1 commentaire
Ala'a Alshubbak
Ala'a Alshubbak le 13 Déc 2022
Modifié(e) : Ala'a Alshubbak le 13 Déc 2022
i am trying same appraoch in saving images of my model.
the model is designed as a project. and i wrote the model name as bellow:
ModelName ='mymodel.slx'
but i got the following error:
###error bellow####
> In checkArgsForHandleToPrint
In checkArgsForHandleToPrint
In print>LocalCreatePrintJob (line 101)
In print (line 38)
Error using checkArgsForHandleToPrint
Simulink system name '/home/jem-user/Downloads/github_repo_matlab_excavator/Models/Complete/Excavator_Complete.slx'
does not exist or is not open.
Error in checkArgsForHandleToPrint
Error in print>LocalCreatePrintJob (line 101)
handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 38)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});
###end of the error####
what is that exactly? any idea to help please.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by