Main Content

Report Model Notes

This example shows how to create a report that embeds model notes. The report includes a chapter for each system in the model. Each chapter includes a system snapshot and any notes for that system.

Open Model

Open a model that has notes.

model = "sldemo_autotrans";
open_system(model);

To open the model notes, in the Modeling tab, under Design, select Model Notes.

Report Setup

Import the Report Generator API namespaces so that you do not have to use long, fully qualified class names.

import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.finder.*

Create and open a Simulink report object. To create a Microsoft® Word, HTML, or single-file HTML report, change "pdf" to "docx", "html", or "html-file", respectively.

rpt = slreportgen.report.Report(model + "_Notes_Report","pdf");
open(rpt);

Add a title page and table of contents.

titlepage = TitlePage("Title",model);
add(rpt,titlepage);
toc = TableOfContents();
add(rpt,toc);

Report on systems

Find and loop through all of the systems in the model.

finder = DiagramFinder(model);
while hasNext(finder)
    system = next(finder);

Create a new chapter and add the system result, which adds a system snapshot to the report.

    ch = Chapter("Title",system.Name);
    add(ch,system);

Add model notes to the current system. If the current system does not have any notes associated with it, nothing is added.

    notes = Notes(system);
    add(ch,notes);   

Add the chapter to the report

    add(rpt,ch);
end

Close Report

Close and view the report.

close(rpt);
rptview(rpt);

See Also

Related Topics