メインコンテンツ

simulink.compiler.genapptemplate

R2026b

Generate a simulation app template from an existing simulation app

Since R2023a

    Description

    simulink.compiler.genapptemplate(appName) generates a simulation app template from an existing simulation app. A simulation app template captures the UI layout, components, and callbacks of an existing simulation app, without model-specific details. The template is a folder containing an .mlapp file and an assets subfolder with supporting resources such as images, CSS, JavaScript®, and HTML files. The function names the generated template SimAppTemplate and saves it in the current working folder. You can customize the template in App Designer, then use it to create new apps for different models without rebuilding the UI from scratch.

    simulink.compiler.genapptemplate(appName,Name=Value) generates a template with additional options specified by one or more name-value arguments. For example, to specify the name and save location of the new template, use TemplateName and OutputDir arguments, respectively.

    Examples

    collapse all

    Create a template from an existing app named myApp and save the template to the folder C:\Templates\MyTemplates.

    By default, simulink.compiler.genapptemplate saves the new template in the current working folder. To save the template in a specific folder, use the OutputDir argument.

    simulink.compiler.genapptemplate("myApp",OutputDir="C:\Templates\MyTemplates")

    To create an app from the generated template:

    By default, if you try to create a template in a folder that contains a template of the same name, the function issues an error.

    If you want the function to create a new template in this case, use the NameConflictHandling option.

    For instance, suppose that the current folder contains an existing template with the name myCustomTemplate. To prevent overwriting, set NameConflictHandling to no-overwrite. With this option, the function names the new template by appending a number to the existing name. This number increments each time you generate a template that uses the existing name.

    simulink.compiler.genapptemplate("myApp",TemplateName="myCustomTemplate",...
                                             NameConflictHandling="no-overwrite")

    To overwrite any existing template with the same name, set NameConflictHandling to overwrite.

    simulink.compiler.genapptemplate("myApp",TemplateName="myCustomTemplate",...
                                             NameConflictHandling="overwrite")

    Input Arguments

    collapse all

    Name of simulation app used to generate the template, specified as a string or character vector. The app must be a simulation app for a Simulink® model.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: TemplateName="myCustomTemplate"

    Name of generated template, specified as a string or character vector.

    Name of the folder containing the generated template files, specified as a string or character vector that defines a full or partial path.

    Option to prevent or allow overwriting of existing template, specified as either "no-overwrite" or "overwrite".

    • "no-overwrite" — Prevents overwriting an existing template. If a template with the specified name already exists, the software appends a number to the template name (for example, SimAppTemplate1, SimAppTemplate2, and so on). The number increments each time you call the function to generate a template that uses an existing name.

    • "overwrite" — Allows overwriting an existing template. If a template with the specified name already exists, the software replaces it with the new template.

    If you do not specify this argument and a template with the same name exists, the software issues an error and does not create a new template or overwrite the existing template.

    Before R2026b: Instead of NameConflictHandling, use ExistingTemplateHandling="rename" to prevent overwriting and ExistingTemplateHandling="overwrite" to allow overwriting.

    Version History

    Introduced in R2023a

    expand all