Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Designer Class / AddNewCableUnit Method
Occurrences that will be added to the newly created cable unit.
If true, all occurrences related to specified ones are also added. Default is true.
Example
In This Topic
    AddNewCableUnit Method
    In This Topic
    Syntax

    Parameters

    occurrences
    Occurrences that will be added to the newly created cable unit.
    includeRelated
    If true, all occurrences related to specified ones are also added. Default is true.

    Return Value

    Created cable unit.
    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.
    This file is not opened.
    Thrown when the occurrence is not part of this document.
    Example
    This example shows how to add a new empty cable unit to the workspace.
    Workspace workspace = ...
    
    IOccCableUnit cableUnit = workspace.AddNewCableUnit();
    
    /*
    IEnumerable<ICableUnitAddable> content = cableUnit.GetContent();
    string result = string.Join(",", cableUnit.GetContent().Select(o => o.Name.ToString()));
    					
    Console.WriteLine(result);
    					
    OUTPUT:
    					
    */
    This example shows how to add a new cable unit with some occurrences and all their related occurrences.
    Workdesk workdesk = ...
    
    // Occurrences from this wordesk:
    ICableUnitAddable wire = workdesk.GetAllOccurrences().FirstOrDefault(o => o.Name.Value == "w_00001");
    ICableUnitAddable bundle = workdesk.GetAllOccurrences().FirstOrDefault(o => o.Name.Value == "b_00001");
    
    IOccCableUnit cableUnit = workdesk.AddNewCableUnit(new[] { wire, bundle });
    
    /*
    IEnumerable<ICableUnitAddable> content = cableUnit.GetContent();
    string result = string.Join(",", cableUnit.GetContent().Select(o => o.Name.ToString()));
    					
    Console.WriteLine(result);
    					
    OUTPUT:
    b_00001,w_00001,w_00002,cn_00001,cn_00002
    */
    This example shows how to add a new cable unit with only selected occurrences.
    Workdesk workdesk = ...
    
    // Occurrences from this wordesk:
    ICableUnitAddable wire = workdesk.GetAllOccurrences().FirstOrDefault(o => o.Name.Value == "w_00001");
    ICableUnitAddable bundle = workdesk.GetAllOccurrences().FirstOrDefault(o => o.Name.Value == "b_00001");
    
    IOccCableUnit cableUnit = workdesk.AddNewCableUnit(new[] { wire, bundle }, false);
    
    /*
    IEnumerable<ICableUnitAddable> content = cableUnit.GetContent();
    string result = string.Join(",", cableUnit.GetContent().Select(o => o.Name.ToString()));
    					
    Console.WriteLine(result);
    					
    OUTPUT:
    b_00001,w_00001
    */
    See Also