Hello, I'm trying to create a mask of a 'parent' block in which the masks of 'child' blocks would appear as tabs (with all parameters promoted to the parent mask). First I create a tab:
parentMask = Simulink.Mask.get(parentBlock);tabs = parentMask.addDialogControl('tabcontainer','tabCont'); tab = tabs.addDialogControl('tab','tab');
Now I'm trying to promote parameter from child and add it to the tab:
childMask = Simulink.Mask.get(childBlock);param = childMask.Parameters(1); %for simplicity
and now I'm stuck in adding the parameter to the tab
props = {'Type','promote',... 'TypeOptions',{[get_param(childBlock,'Name'),'/',param.Name],... %not documented?, guessed by reverse-engineering 'Name',param.Name,... 'Prompt',param.Prompt,... 'TabName',tab.Name};parentMask.addParameter(props{:});
but I get: Warning: 'TabName' cannot be set for 'system/parentBlock' as it will be removed in a future release. Use tab dialog controls to add parameters to tabs
I could not figure out a way how to add parameters to the tab as suggested by the hint. It is not documented (yet?).
1) How do I add any parameter to tab programmatically?
2) Or better, in the object world, is there a chance to promote a parameter just by passing its handle, for example by:
tab.addParameter('Type','promote',param)
There are also some bugs I've found on the way:
- example from https://nl.mathworks.com/help/simulink/slref/simulink.maskparameter.set.html does not work ('TabName' property)
- properties in https://nl.mathworks.com/help/simulink/slref/simulink.mask.adddialogcontrol.html contain a strange 'Filepath' property, probably just instead of 'TabName'
- there is no way how to discover/remove dialog controls without knowing their name. Magically, however, https://nl.mathworks.com/help/simulink/ug/control-masks-programmatically.html contains undocumented method getDialogControls, which can serve the purpose. Or by another undocumented way by invoking parentMask.DialogControls property.
The object-oriented way to mask creation is a big step towards user-friendliness when it comes to mask creation. I hope resolving these issues will help to move the cause further.
Thank you.
Best Answer