I am writing a Model Advisor check right now and I need to know the size of a subcharted Stateflow State or Box. But the "Stateflow.State" and "Stateflow.Box" objects only have a "Position" attribute, which gives their position inside their parent elements. I need to know the size of the subchart itself (where their contents reside). How can I get this size?
I finally asked the MathWorks support for a solution and got this answer:
[...] there is currently no API functionality to retrieve the size of the subchart in the subchart subviewer. Unfortunately there are no workarounds to access this information currently.
Update: I recently learned about the undocumented sf
API. It is possible to get information about the subchart with it. Therefore you need to get the ID of the State whos dimensions are needed. Here is an example:
r = sfroot;
s = r.find('-isa', 'Stateflow.State', '-and', 'IsSubchart', 1);
sf('get', s(1).id, '.subviewS.pos')
This does the following:
Simulink.Root
object in r
.s
. You might need to refine the search to detect the exact State you need.sf
API to retrieve the position .pos
of the first Subchart, which is represented by .subviewS
There is plenty of information about each of the Stateflow objects. To investigate further, you just need to find the appropriate object (using r.find()
) and use sf('get', <object>.id)
. This lists all available information about the Stateflow object <object>
.