Main Content

Create and Register Templates in the Safety Analysis Manager

If you have a format that you want to use for documents that you create in the Safety Analysis Manager, you can create templates. If you want to use a template often, you can register the template to organize and display them for easier access.

Create and Load Safety Analysis Manager Templates

To create a template, load or create a document in the Safety Analysis Manager. For more information, see Create Spreadsheets in the Safety Analysis Manager. Then, in the File section, expand Save and click Export Template. The Safety Analysis Manager saves the template as an MLDATX file.

Template files retain callbacks, the number and type of columns, the column formulas in derived columns, and the number of document attributes and their properties. Templates do not retain the number of rows, cell values, or document attribute values.

You can also save template spreadsheets programmatically. To create a template retrieve the Spreadsheet object of the spreadsheet and then save the template by using the saveTemplate function.

Register Safety Analysis Manager Templates

If you plan on using templates frequently, you can register your template. Registering a template adds it to the list of available templates when you create a new spreadsheet. To register templates, configure an sl_customization.m file. See Register Customizations with Simulink.

For example, suppose you want to register a template myTemplate.mldatx in the group myGroup and you want to assign an image, myThumbnail.png , to the registered template. You also want to give the template a brief description. To register this template:

  1. Create a new sl_customization function by creating a sl_customization.m file and entering this in the header:

    function sl_customization(cm)

  2. In the next line, use the SafetyAnalysisMgrCustomizer.registerCustomTemplate function.

    cm.SafetyAnalysisMgrCustomizer.registerCustomTemplate("myGroup",...
        "mytemplate.mldatx",...
        Icon = "myThumbnail.png",...
        Description = "This is my custom template");
    

    The function takes two required arguments and two optional arguments.

    • The first argument is the group name, specified as a string scalar or a character vector.

    • The second argument is the template name, specified as a string scalar or a character vector. The template name must include the .mldatx extension. If the template is in a different folder than the working folder, specify the relative path to the template.

    • The first name-value argument is an optional icon file, specified as a string scalar or character vector. You must include the image extension in the argument. If the template is in a different folder than the working folder, specify the relative path to the template. If you don't specify this name-value argument, the registered template uses a default icon.

    • The second name-value is an optional description, specified as a string scalar or character vector. The description appears below the thumbnail.

  3. Save the sl_customization.m file and, in the Command Window, enter sl_refresh_customizations.

To create a new template, in the Safety Analysis Manager, click New. The registered template appears in the Safety Analysis Manager window in the specified group.

The safety Analysis Manager window after registering the template described previously. The group,myGroup, includes a template with an icon.

To unregister the template, remove the SafetyAnalysisMgrCustomizer.registerCustomTemplate function from the sl_customization.m file and rerun sl_refresh_customizations.

See Also

|

Related Topics