Working with product variants
This explains how to work with product variants.
Selecting features
To select features in the target product, use the SelectFeature method of the IProduct object. To select features by specifying their names, use the SelectFeaturesByName method.
public void SelectFeature(ICommandContext c, ICommandParams p)
{
var configurationModel = c.App.Workspace.CurrentProject.ProductLineModel.ConfigurationModel;
IProduct product = configurationModel.GetProduct("ACC-0011");
//Select the feature with the specified name
product.SelectFeatureByName("camera");
//Select all features with the specified name
product.SelectFeaturesByName("camera, radar, airbag");
//Select by feature
IFeature feature = ...
product.SelectFeature(feature);
}
Deselect a feature
To deselect a feature in the target product, use the DeselectFeature method of the IProduct object. To select a feature by specifying its name, use the DeselectFeatureByName method.
public void DeselectFeature(ICommandContext c, ICommandParams p)
{
var configurationModel = c.App.Workspace.CurrentProject.ProductLineModel.ConfigurationModel;
IProduct product = configurationModel.GetProduct("ACC-0011");
//Deselect the feature with the specified name
product.DeselectFeatureByName("camera");
//Deselect all features with the specified name
product.DeselectFeaturesByName("camera, radar, airbag");
//Deselect by feature
IFeature feature = ...
product.DeselectFeature(feature);
}