Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Variant Class / CreateCableDrawingFromTemplate Method
Name of the new cable drawing. No two cable drawings in the project can have the same name.
Path to the template file (*.hxct).
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. If not provided then it is taken from the template.
Example
In This Topic
    CreateCableDrawingFromTemplate Method
    In This Topic
    Create new cable drawing from template file in this variant.
    Syntax

    Parameters

    name
    Name of the new cable drawing. No two cable drawings in the project can have the same name.
    templatePath
    Path to the template file (*.hxct).
    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. If not provided then it is taken from the template.

    Return Value

    New cable drawing.
    Exceptions
    Example
    This example shows how to create new cable drawing from template.
    // 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");
    
    // Open a variant.
    // Let's 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 a 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 those, whose name starts with underscore.
    IEnumerable<CableUnitInfo> selectedCableUnits = allCableUnits.Where(n => n.DocumentName == "MyWorkspace").Where(n => n.Name.StartsWith("_"));
    
    // Now let's derive the final cable drawing using information we gathered.
    CableDrawing newCableDrawing = variant.CreateCableDrawingFromTemplate("New cable drawing name", "Path to the template file", selectedCableUnits);
    
    // Save and close the project.
    project.Save();
    project.Close();
    
    // Close the API.
    api.Close();
    This example shows how to create new cable drawing from template and use a selected display configuration.
    // Open a project.
    Project project = ...
    
    // Get all display configurations in the project and find the one called "favorite".
    CableDrawingDisplayConfigurationInfo displayConfiguration = project.GetCableDrawingDisplayConfigurations().Where(n => n.Name == "favorite").FirstOrDefault();
    
    // Open a variant.
    Variant variant = project.GetVariants().FirstOrDefault();
    
    // Get list of all cable units in this variant.
    List<CableUnitInfo> allCableUnits = variant.GetAllCableUnitInfos();
    
    // Now let's derive the final cable drawing using information we gathered.
    CableDrawing newCableDrawing = variant.CreateCableDrawingFromTemplate("New cable drawing name", "Path to the template file", allCableUnits, displayConfiguration);
    
    // Save and close the project.
    project.Save();
    project.Close();
    See Also