Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / GraphicDocument Class / GetAllOccurrences Method / GetAllOccurrences<T>() Method
Type of occurrence to be listed.
Example
In This Topic
    GetAllOccurrences<T>() Method
    In This Topic
    Get all occurrences of type T in this document.
    Syntax
    public IEnumerable<T> GetAllOccurrences<T>()
    where T: IOccurrence

    Type Parameters

    T
    Type of occurrence to be listed.

    Return Value

    Returns list of occurrences of type T in this document.
    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 operation was denied because of your license.
    This file is not opened.
    Example
    // API is a singleton.
    HpdApi api = HpdApi.GetInstance();
    
    // Initialize API and load HpD.
    api.Init();
    
    // Open a Harness proD project.
    Project project = api.OpenProject(@"Path to the project");
    
    // Select the desired variant.
    Variant variant = project.GetVariants().FirstOrDefault(v => v.Name == "variant name");
    
    // Select and open the desired document (for example workspace).
    Workspace workspace = variant.GetWorkspaces().FirstOrDefault(w => w.Name == "workspace name");
    workspace.Open(false, false);
    
    // List of all connector occurrences in this document.
    List<OccWsCable> occs = workspace.GetAllOccurrences<OccWsConnector>.ToList();
    					
    // CLose the document.
    workspace.Close();
    					
    // Close the project.
    project.Close();
    
    // Close the API.
    api.Close();
    See Also