Main Content

lock

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

Lock mask part reference container to prevent editing

Since R2024b

Syntax

maskPartRefObj.lock

Description

maskPartRefObj.lock locks the mask part reference container maskPartRefObj to prevent editing. A mask part reference container saves parameters and dialog controls in an XML file. The XML file is referred to and reused across multiple block masks. Locking the mask part reference container after saving the mask prevents accidental changes from being propagated to the XML file.

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";

Unlock the mask part reference container to add a Push button dialog control.

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

Lock the mask part reference container.

maskPartRefObj.lock;

Add text dialog control to the mask part reference container.

maskPartRefObj.addDialogControl(Name='impedance',Type='text',Prompt='Impedance',Visible='off');

The MATLAB command window displays an error when you try to add a parameter or dialog control to the locked mask part reference container.

Alternatives

Use the Mask Editor UI to lock the mask part reference container.

Version History

Introduced in R2024b