Main Content

sl_refresh_customizations

Refresh customizations in the current MATLAB session

Since R2022a

    Description

    example

    sl_refresh_customizations:

    • Runs all sl_customization.m files on the MATLAB® path and in the current folder

    • Rebuilds the Simulink® Toolstrip

    • Rebuilds all Simulink Editor menus

    • Rebuilds the Simulink Library Browser menus and toolbars

    • Clears the Library Browser cache and refreshes the Library Browser

    • Reloads the Viewers and Generators Manager data

    Examples

    collapse all

    Use the sl_refresh_customizations command to show the changes that an sl_customization.m file makes to the order of the libraries in the Simulink Library Browser and the changes that a modified JSON file makes to the Simulink Toolstrip. Start by changing the order of the libraries in the Library Browser. By default, the libraries are listed in ascending order of priority, and libraries that have the same priority are in alphabetical order. The Simulink library has a sort priority of -1. All other libraries have a sort priority of 0. The Simulink library is the first library listed in the browser because it has the highest priority.

    Open a blank model in Simulink.

    Open the Simulink Library Browser. The first library listed in the browser is the Simulink library.

    Create an sl_customization.m file that gives the Simulink Extras library a priority of -2. This priority is higher than that of the Simulink library.

    function sl_customization( cm )
       cm.LibraryBrowserCustomizer.applyOrder({'Simulink Extras',-2});
    end

    Save the sl_customization.m file to the MATLAB path.

    Check the Simulink Library Browser. The order of the libraries is unchanged.

    The Simulink Library Browser libraries in their default order with the Simulink library at the top

    Now, modify the toolstrip. Create an empty custom toolstrip tab by entering this in the MATLAB Command Window.

    slCreateToolstripComponent("custom");
    slCreateToolstripTab("customTab","custom",Title="CUSTOM TAB");

    In the customTab.json file that is generated, change the title of the tab from CUSTOM TAB to NEW NAME.

    {
      "version": "1.0",
      "entries": 
      [
        {
          "type": "Tab",
          "id": "customTab",
          "title": "NEW TAB"
        }
      ]
    }

    Save the customTab.json file.

    Check the title of the custom tab. Even though the title in the customTab.json file is now NEW NAME, the title displayed in the toolstrip is still CUSTOM TAB.

    The Simulink Toolstrip with a custom tab titled CUSTOM TAB

    To see your changes implemented on the Library Browser and toolstrip, rebuild both with this single command.

    sl_refresh_customizations

    Check the Library Browser. The order of the libraries has changed: the Simulink Extras library is above the Simulink library.

    The Simulink Library Browser libraries in the new order with the Simulink Extras library moved to the top of the list

    Check the toolstrip. The name of the custom tab has changed from CUSTOM TAB to NEW TAB.

    The Simulink Toolstrip with a custom tab titled NEW TAB

    Tips

    If you only need to refresh the Library browser displayed in the current MATLAB session, you can also do so using the refresh command.

    If you only need to refresh the toolstrip displayed in the current MATLAB session, you can also do so using the slReloadToolstripConfig command.

    Version History

    Introduced in R2022a