how can i access to the export button on the architecture views of the system composer, using code?

4 ビュー (過去 30 日間)
I want to access the "export" button that is in the toolstrip of the architecture view tab, through code. Is it possible that with code or some function, I can export a view as if I had pressed the "export" button?
I have tried creating a report, but the images of the view are bad quality, it does not get the same quality and page orientation as if i clicked the export button.
  1 件のコメント
Saurav
Saurav 2024 年 8 月 19 日
As of now, this feature isn't supported by MATLAB to export the architecture view programmatically.

サインインしてコメントする。

採用された回答

Josh Kahn
Josh Kahn 2024 年 8 月 19 日
編集済み: Josh Kahn 2024 年 8 月 19 日
Thanks for reaching out! The view export resolution with report generator is a known issue that we are investigating. If you send me a private message with your email address, I can get you a workaround.
Josh

その他の回答 (1 件)

Malay Agarwal
Malay Agarwal 2024 年 8 月 19 日
You can use the Simulink Report Generator toolbox (https://www.mathworks.com/products/simulink-report-generator.html) with System Composer APIs to export an architectural view as an image. Please refer to the following example, which demonstrates how to do this: https://www.mathworks.com/help/releases/R2023a/systemcomposer/ug/report-generation-system-architectures.html.
In the "Architecture Views" section of the example (https://www.mathworks.com/help/releases/R2023a/systemcomposer/ug/report-generation-system-architectures.html#ReportGenerationForSystemArchitecturesExample-4), the "systemcomposer.rptgen.finder.ViewFinder" class is used to find all architectural views in the model. It then loops over all the views and adds them to a report. The image in the report is equivalent to the image you get using the Export button.
If you want the resultant PDF to just have the views, you can skip adding any title page, table of contents, sections or chapters. You can then access the "Snapshot" property of each view to append just an image of the view to the report. For example:
% Create a report
rpt = slreportgen.report.Report('OutputPath','SystemModel'+".pdf",...
'CompileModelBeforeReporting',false);
% Change the orientation to landscape
rpt.Layout.Landscape = true;
% TODO - Replace with your model
model = systemcomposer.loadModel("mTestModel");
% Find all the views using "ViewFinder"
view_finder = systemcomposer.rptgen.finder.ViewFinder(model.Name);
% Loop over all the views
while(hasNext(view_finder))
v = next(view_finder);
% Create a Image using the Snapshot property of the view
img = mlreportgen.dom.Image(which(v.Snapshot.Image));
% Change the style to scale the image to the page size
img.Style = {mlreportgen.dom.ScaleToFit};
% Append the image to the report
append(rpt, img);
end
% View the report
rptview(rpt)
The model that I've used in the above code and generated report are attached to the answer.
Please refer to the following resources for more information:
Hope this helps!

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by