Main Content

slreportgen.finder.DiagramElementFinder class

Package: slreportgen.finder

Create diagram element finder object

Description

Finds elements in a Simulink® block or Stateflow® chart diagram.

The slreportgen.finder.DiagramElementFinder class is a handle class.

Creation

Description

example

finder = DiagramElementFinder(diagram) creates a finder that finds elements of a Simulink block or Stateflow chart diagram. By default this finder finds blocks, annotations, lines, states, and other elements in the diagram. Use the properties of the finder to constrain the search to specific types of elements.

Note

This finder provides two ways to get search results:

  1. To return the search results as an array, use the find method. Add the results directly to a report or process the results in a for loop.

  2. To iterate through the results one at a time, use the hasNext and next methods in a while loop.

Neither option has a performance advantage.

finder = DiagramElementFinder(Name=Value) sets properties using name-value arguments. You can specify multiple name-value arguments in any order.

Input Arguments

expand all

See Container property.

Properties

expand all

Diagram in which to search, specified as one of these values:

  • Handle to a Simulink block

  • Path to a Simulink block

  • Handle to a Stateflow chart block

  • Path to a Stateflow chart block

  • Stateflow chart ID

  • Stateflow chart object

Types of Simulink or Stateflow diagram elements to find, specified as a string, character array, array of strings, or a cell array of character arrays. If the type is an array, it specifies a set of element types. The default is All or all, which finds all elements in all diagrams. Use one of these values to constrain the search to specific diagram element types. You can use either the fully qualified name or the short name.

Fully Qualified NameShort Name
Allall
Simulink.Annotationannotation
Simulink.Blockblock
Simulink.Segmentline
Simulink.Portport
Stateflow.Annotationsf_annotation
Stateflow.Boxbox
Stateflow.EMFunctionemfunction
Stateflow.Functionfunction
Stateflow.Junctionjunction
Stateflow.Portsf_port
Stateflow.SLFunctionslfunction
Stateflow.Statestate
Stateflow.Transitiontransition
Stateflow.TruthTabletruthtable

Choice to include commented-out diagram elements in the search results, specified as a logical. If false, commented-out elements are excluded from the search results.

Variants to search for diagrams, specified as a string or character vector. The default value is Active. Valid values are:

  • All — All variants

  • Active — Only active variants

  • ActivePlusCode — All active variants and code variants

Number of levels to search Container, specified as one of these values:

ValueDescription
[] (default)
  • If Container is a block diagram, search only the top level of the diagram.

  • If Container is a Stateflow chart diagram, search only for elements visible from the top level of the chart. The search includes elements in nested states but excludes elements in subcharts.

nonnegative integer

Search the specified number of levels

inf

Search all levels

Properties of objects to find, specified as a cell array of name-value pairs. The finder returns only objects that have the specified properties with the specified values.

Example: finder.Properties = {'Gain','5'}

Methods

expand all

Examples

collapse all

Find the block, annotation, and line diagram elements to a search depth of 1 in the f14 model.

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

model_name = "f14";
load_system(model_name);

rpt = slreportgen.report.Report("output","pdf");
add(rpt, TitlePage(Title=sprintf("%s Model",model_name)));
add(rpt, TableOfContents);

diagFinder = SystemDiagramFinder(Container=model_name,SearchDepth=1);
while hasNext(diagFinder)
    system = next(diagFinder);
    chapter = Chapter(Title=system.Name);
    add(chapter,system);
    sect = Section(Title="Diagram Elements");
    elemFinder = DiagramElementFinder(...
                        Container=system.Object,...
                        Types=["block" "annotation" "line"]);
    elems = find(elemFinder);
    for elem = elems
        add(sect, elem);
    end  
    add(chapter, sect);
    add(rpt, chapter);
end

close(rpt);
close_system(model_name);
rptview(rpt);

Version History

Introduced in R2017b