Main Content

save

Class: Simulink.dialog.MaskPartReference
Namespace: Simulink.dialog

Save contents of mask part reference container to XML file

Since R2024b

Syntax

maskPartRefObj.save

Description

maskPartRefObj.save saves the parameters and dialog controls of the mask part reference container to the XML file specified in the FileName property of the mask part reference object.

Examples

expand all

Load the model.

model = "slexMaskingBasic.slx";
load_system(model);

Get the mask object and add mask part reference container to it.

maskObj = Simulink.Mask.get("slexMaskingBasic/mx + b");
maskPartRefObj = maskObj.addDialogControl(Type="maskpartreference",Name="MaskPartRefContainer");

Specify the XML file containing mask parameters and dialog controls.

maskPartRefObj.FileName = "main_mask_part_ref.xml";
maskPartRefObj.load;

List the existing parameters and dialog controls in the mask part reference container.

maskPartRefObj
maskPartRefObj = 
  MaskPartReference with properties:

              Name: 'MaskPartRefContainer'
          FileName: 'main_mask_part_ref.xml'
    InstanceValues: {0x1 cell}
               Row: 'new'
           Enabled: 'on'
           Visible: 'on'
      AlignPrompts: 'off'
    DialogControls: [1x4 Simulink.dialog.Control]
           Tooltip: ''

Add a dialog control to the mask part reference container and use the save method to save the dialog control to the XML file.

maskPartRefObj.unlock;
maskPartRefObj.removeDialogControl('addcontrol');
maskPartRefObj.addDialogControl(Name='addcontrol',Type='pushbutton',Prompt='Add',Visible='off');

maskPartRefObj.save;

Display the contents of the mask part reference object and observe that it contains five dialog control elements.

maskPartRefObj
maskPartRefObj = 
  MaskPartReference with properties:

              Name: 'MaskPartRefContainer'
          FileName: 'main_mask_part_ref.xml'
    InstanceValues: {0x1 cell}
               Row: 'new'
           Enabled: 'on'
           Visible: 'on'
      AlignPrompts: 'off'
    DialogControls: [1x5 Simulink.dialog.Control]
           Tooltip: ''

Remove the addcontrol dialog control ans save the mask part reference container.

maskPartRefObj.unlock();
maskPartRefObj.removeDialogControl('addcontrol');
maskPartRefObj.save;

Alternatives

Use the Mask Editor UI to save the parameters and dialog controls of the mask part reference container to an XML file.

Version History

Introduced in R2024b