Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Variant Class / CreateCableDrawing Method
Name of the new cable drawing. No two cable drawings in the project can have the same name.
Cable units from which this cable drawing will be derived. Only valid cable units are allowed. (Check EPLAN.Harness.API.Occurrences.Interfaces.IOccCableUnit.IsCableUnitValid.) Only cable units from one type of designer are allowed (all from Workspaces or all from Workdesks).
Display configuration. Obtain from Project.GetDefaultCableDrawingDisplayConfiguration or Project.GetCableDrawingDisplayConfigurations.
Example
In This Topic
    CreateCableDrawing Method
    In This Topic
    Create a new cable drawing in this variant
    Syntax

    Parameters

    name
    Name of the new cable drawing. No two cable drawings in the project can have the same name.
    cableUnits
    Cable units from which this cable drawing will be derived. Only valid cable units are allowed. (Check EPLAN.Harness.API.Occurrences.Interfaces.IOccCableUnit.IsCableUnitValid.) Only cable units from one type of designer are allowed (all from Workspaces or all from Workdesks).
    displayConfiguration
    Display configuration. Obtain from Project.GetDefaultCableDrawingDisplayConfiguration or Project.GetCableDrawingDisplayConfigurations.

    Return Value

    New cable drawing
    Exceptions
    Example
    // API is a singleton.
    HpdApi api = HpdApi.GetInstance();
    
    // Initialize API and load HpD.
    api.Init();
    
    // Open a project.
    Project project = api.OpenProject("path to my project");
    
    // Get all display configurations in the project and find the one called "My favourite display configuration".
    CableDrawingDisplayConfigurationInfo displayConfiguration = project.GetCableDrawingDisplayConfigurations().Where(n => n.Name == "My favourite display configuration").FirstOrDefault();
    
    // If your favourite display configuration was not found, grab a default one.
    if (displayConfiguration == null)
    {
    	displayConfiguration = project.GetDefaultCableDrawingDisplayConfiguration();
    }
    
    // Open a variant.
    // Let us assume there is only one variant in the project, so we simply pick it.
    Variant variant = project.GetVariants().FirstOrDefault();
    
    // Get list of all cable units in this variant.
    // You will not get the real cable unit objects, just smaller structures which contain basic info about the cable unit such as ID, name and the same info about its parent document.
    List<CableUnitInfo> allCableUnits = variant.GetAllCableUnitInfos();
    
    // Now we filter only cable units from document "MyWorkspace" and only the ones with name starting with underscore.
    IEnumerable<CableUnitInfo> selectedCableUnits = allCableUnits.Where(n => n.DocumentName == "MyWorkspace").Where(n => n.Name.StartsWith("_"));
    
    // Now let us derive the final cable drawing using information we gathered.
    CableDrawing newCableDrawing = variant.CreateCableDrawing("New cable drawing name", selectedCableUnits, displayConfiguration);
    
    // Now we can do stuff with our new cable drawing. For example we can revise it.
    // Or we can just throw this object away, since we can always get it using variant.GetCableDrawings();
    newCableDrawing.Revise();
    
    // Save and close the project.
    project.Save();
    project.Close();
    
    // Close the API.
    api.Close();
    See Also