Associate configuration set or configuration reference with model


attachConfigSet(model, configObj)
attachConfigSet(model, configObj, allowRename)



The name of an open model, or gcs to specify the current model


A configuration set (Simulink.ConfigSet) or configuration reference (Simulink.ConfigSetRef)


Boolean that determines how Simulink® software handles a name conflict


attachConfigSet associates the configuration set or configuration reference (configuration object) specified by configObj with model.

You cannot attach a configuration object to a model if the configuration object is already attached to another model, or has the same name as another configuration object attached to the same model. The optional Boolean argument allowRename determines how Simulink software handles a name conflict between configuration objects. If allowRename is false and the configuration object specified by configObj has the same name as a configuration object already attached to model, Simulink software generates an error. If allowRename is true and a name conflict occurs, Simulink software provides a unique name for configObj before associating configObj with model.


The following example creates a copy of the current model's active configuration object and attaches it to the model, changing its name if necessary to be unique. The code is the same whether the object is a configuration set or configuration reference.

myConfigObj = getActiveConfigSet(gcs);
copiedConfig = myConfigObj.copy;
copiedConfig.Name = 'DevConfig';
attachConfigSet(gcs, copiedConfig, true);

Introduced before R2006a

Was this topic helpful?