MATLAB: How can the handle to the currently visible Stateflow.Box object be obtained

stateflow

It is possible to obtain the handle to the currently visible Stateflow.Chart object by using the following command:
>> s = sfroot;
>> c = s.find('-isa', 'Stateflow.Chart', '-and', 'Visible', 1);
What is the equivalent property for a Stateflow.Box object? The following command returns an empty 0x1 handle:
>> b = s.find('-isa', 'Stateflow.Box', '-and', 'Visible', 1);

Best Answer

The command returns an empty handle because the Stateflow.Box constructor does not have a 'Visible' method. Hence, it would not be possible to programmatically query the currently visible Box object similar to how a Chart object is queried.
There are two possible ways in which this can be achieved:
1. If you are interested in programmatically querying and obtaining a handle to a currently visible Stateflow Object (chart, box, state etc.), click on the object-of-interest* *and then *u*se the 'sfgco' command. Documentation here:
2. If you are already aware about the names of the objects to be queried, then it is possible to directly filter these objects out by using their names:
>> c = s.find('-isa', 'Stateflow.Chart', '-and', 'Name', 'chart_name');
>> b = s.find('-isa', 'Stateflow.Box', '-and', 'Name', 'box_name');
Using the 'Name' property would return the handles to the required objects directly.