Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Designer Class / CreateCableUnits Method
Defines which cables to use and how to create the cable units.
Example
In This Topic
    CreateCableUnits Method
    In This Topic
    Creates cable units based on cables, cable will become backbone of a cable unit.
    Syntax

    Parameters

    settings
    Defines which cables to use and how to create the cable units.

    Return Value

    Created cable units.
    Exceptions
    ExceptionDescription
    Argument is null.
    Api is not in an initialized state. You can get current state from EPLAN.Harness.API.Studio.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.Studio.Init method. If API is in failed state, you can not resurrect it.
    Example
    Creating cable units based on cables
    Studio api = Studio.GetInstance();
    api.Init(@"C:\Program Files\EPLAN\EPLAN Harness proD 2022");
    // Open project and variant and document.
    Project project = api.OpenProject(@"C:\Users\user\Documents\Harness proD 2022\Projects\My project.hxproj");
    
    Variant variant = project.GetVariants()[0];
    Designer designer = variant.GetWorkspaces().FirstOrDefault(wsp => wsp.Name == "Workspace 1");
    designer.Open(false, false);
    
    // Select a desired occurrence.
    List<Cable>cables = designer.GetAllOccurrences().OfType<ICable>().ToList();
    
    ApiCableUnitGeneratorSettings settings = new ApiCableUnitGeneratorSettings(true, true, true, true, true, true, true, cables);
    designer.CreateCableUnits(settings);
    
    // Save changes and close documents.
    designer.Save();
    designer.Close();
    See Also