Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Variant Class / ElectricalConfigurationsSettings Property
Example
In This Topic
    ElectricalConfigurationsSettings Property
    In This Topic
    Gets or sets list of electrical configurations of this variant.
    Syntax
    public IList<ElectricalConfigurationSetting> ElectricalConfigurationsSettings {get; set;}
    Exceptions
    ExceptionDescription
    Api is not in an initialized state. You can get current state from EPLAN.Harness.API.HpdApi.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.HpdApi.Init method. If API is in failed state, you can not resurrect it.
    The object is in invalid state. Obtain a new one.
    Argument is null.
    This file is not opened.
    You can not perform this action on a document opened as read only.
    The exception that is thrown when electrical configuration with this name already exists in this variant.
    Remarks
    This property returns BindingList so all changes are directly propagated to the Harness project. See examples.
    Example
    The following example shows how to edit an existing electrical configuration.
    // Obtain variant.
    Variant variant = ...
    variant.Open(false, false);
    
    // Get list of electrical configurations.
    IList<ElectricalConfigurationSetting> electricalConfigurations = v.ElectricalConfigurationsSettings;
    
    // Get desired electrical configuration.
    ElectricalConfigurationSetting myConfiguration = electricalConfigurations.FirstOrDefault(c => c.Name == "Name of the configuration");
    if (myConfiguration == null)
    {
    	// Resolve this.
    }
    
    // Change description.
    myConfiguration.Description = "New description from API";
    
    // Set all electrical options of this electrical configuration to true.
    foreach (ElectricalOption elOption in myConfiguration.ElectricalOptions)
    {
    	elOption.IsUsed = true;
    }
    
    // Save changes.
    variant.Save();
    The following example shows how to delete an existing electrical configuration and add a new electrical configuration.
    // Obtain variant.
    Variant variant = ...
    variant.Open(false, false);
    
    // Get list of electrical configurations.
    IList<ElectricalConfigurationSetting> electricalConfigurations = v.ElectricalConfigurationsSettings;
    
    // Get desired electrical configuration.
    ElectricalConfigurationSetting deleteConfiguration = electricalConfigurations.FirstOrDefault(c => c.Name == "Configuration for delete");
    if (deleteConfiguration == null)
    {
    	// Resolve this.
    }
    
    // Delete the electrical configuration.
    electricalConfigurations.Remove(deleteConfiguration);
    
    // Add a new electrical configuration.
    ElectricalConfigurationSetting myNewConfiguration = new ElectricalConfigurationSetting("APIConfig", "00023", "API is awesome!");
    electricalConfigurations.Add(myNewConfiguration);
    
    // Save changes.
    variant.Save();
    See Also