Main Content

attachConfigSetCopy

Copy configuration set or configuration reference and associate it with model

Description

example

configObjCopy = attachConfigSetCopy(model, configObj) creates a copy of the configuration set or configuration reference configObj and associates it with model. The function returns the copy of the configuration as a Simulink.ConfigSet object or a Simulink.ConfigSetRef object.

example

attachConfigSetCopy(model, configObj, allowRename) associates the configuration copy with the model and determines how Simulink® handles a name conflict between the configuration and any configuration objects that are already attached to the model.

If allowRename is false and the configuration object specified by configObj has the same name as a configuration object already attached to model, Simulink generates an error. If allowRename is true and a name conflict occurs, Simulink provides a unique name for the copy of configObj before associating it with the model.

Examples

collapse all

This example shows to create a copy of the active configuration for the model sldemo_bounce and attach the copy to the model sldemo_boiler.

Open the model sldemo_bounce and get the active configuration object.

sldemo_bounce
slbounceConfigObj = getActiveConfigSet('sldemo_bounce');

Each model has a configuration with the default name Configuration. To avoid a naming conflict when you attach the configuration copy to sldemo_boiler, name the configuration slbounceConfig.

set_param(slbounceConfigObj,'Name','slbounceConfig');

Open the model sldemo_boiler. Copy the configuration object slbounceConfigObj and attach it to sldemo_boiler.

sldemo_boiler
attachConfigSetCopy('sldemo_boiler',slbounceConfigObj);

To use the configuration in sldemo_boiler, activate it.

This example shows to create a copy of the active configuration for the model sldemo_bounce and attach the copy to the model sldemo_boiler. Use the allowRename argument to avoid naming conflicts.

Open the model sldemo_bounce and get the active configuration object.

sldemo_bounce
slbounceConfigObj = getActiveConfigSet('sldemo_bounce');

Open the model sldemo_boiler. Copy the configuration object slbounceConfigObj and attach it to sldemo_boiler. Specify allowRename as true.

sldemo_boiler
attachConfigSetCopy('sldemo_boiler',slbounceConfigObj,true);

Because the model already has a configuration set named Configuration, Simulink® changes the name of slbounceConfigObj to Configuration1 before attaching it to sldemo_boiler.

To use the configuration in sldemo_bounce, activate Configuration1.

Input Arguments

collapse all

Model to which you want to attach a configuration set, specified as a character vector or string scalar. The model must be open.

Example: 'my_model'

Configuration object that you want to copy, specified as a Simulink.ConfigSet object or a Simulink.ConfigSetRef object.

Example: myConfigObj

Specification that determines if Simulink renames the configuration object copy in the case of a name conflict, specified as a Boolean. If allowRename is false and a name conflict occurs, Simulink generates an error.

Example: true

Introduced in R2006b