Copy subsystem mask to model mask
Show older comments
Hi, I'm trying to move my library blocks to Model Reference. Every block has its own mask and I don't want to re-create all the masks. Popup are often used inside the masks and automatic conversion from subsystem to Model Reference does not work.
This is the procedure I'm following on MATLAB 2017b:
1) Copy the library block on a new model and save the model as 'newModel'
2) Disable and break library links
3) Move the content of the block on the model
4) Define the model parameters (with the 'Argument' option enabled) on the Model explorer
5) Try to copy the subsystem mask to the model mask as follows:
mks = Simulink.Mask.get('newModel/1-axis Conditioning')
pDest = Simulink.Mask.create('newModel')
pDest.copy(mks)
Then, It returns the following error:
Incorrect to change the number of mask parameters in model
'newModel'.
Can someone help me? I really don't get what I should do, I've found no similar error on the Internet so I suppose there are some basic facts that I'm missing.
1 Comment
Spencer Ochsner
on 23 Jan 2021
I am having the same error, using the code from https://www.mathworks.com/help/simulink/slref/simulink.mask.copy.html
Except, I am making a mask on the root model. (This model will be referenced elsewhere.)
pSource = Simulink.Mask.get(srcBlockName)
pDest = Simulink.Mask.create(gcs)
pDest.copy(pSource)
Using 2017a.
Answers (1)
Fangjun Jiang
on 25 Sep 2018
0 votes
Are you supposed to add a "Model" block to your "newModel"? You can't mask the root level model. Rather, you can copy the mask to the mask of the "Model" block.
5 Comments
Alberto Brandl
on 25 Sep 2018
Fangjun Jiang
on 25 Sep 2018
But your code indicated otherwise. Could you try
pDest = Simulink.Mask.create('newModel/ModelBlock')
Where "ModelBlock" is the "Model" block you added. It references the model file in which you copied the contents of the library block.
Alberto Brandl
on 25 Sep 2018
Fangjun Jiang
on 25 Sep 2018
Edited: Fangjun Jiang
on 25 Sep 2018
As far as I know, mask is for blocks, not for models. A model needs to be able to run simulation with necessary data. What do you expect if a model has a mask? Where and in what format do you expect the mask of this model behave if the user just opens this model?
I would imagine you create another model, add a "Model" block called "ModelBlock" to reference this model file (newModel.slx), and then copy the mask to this "ModelBlock".
You need to add "arguments" to your "newModel". See the doc link below for how to do it. These arguments are the variables that you need to assign through the mask that you will copy to the "ModelBlock".
web(fullfile(docroot, 'simulink/ug/parameterize-referenced-models_bvmkw_k-1.html#bvmkxdx-1'))
Spencer Ochsner
on 23 Jan 2021
Yes, root models can have masks.
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

