Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / GraphicDocument Class / GetEnvironmentOccurrences Method
Example
In This Topic
    GetEnvironmentOccurrences Method (GraphicDocument)
    In This Topic
    Get environment occurrences in this document.
    Syntax
    public abstract IEnumerable<BaseOccurrence> GetEnvironmentOccurrences()

    Return Value

    Returns list of all environment occurrences 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.
    Remarks
    All environment occurrences implement EPLAN.Harness.API.Occurrences.Interfaces.IEnvironmentOccurrence interface.
    Example
    This example shows how to get all environment occurrences in this document.
    // 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 workdesk).
    Workdesk workdesk = variant.GetWorkdesks().FirstOrDefault(w => w.Name == "workdesk name");
    workdesk.Open(false, false);
    
    // List of environment occurrences in this document.
    List<BaseOccurrence> occs = workdesk.GetEnvironmentOccurrences().ToList();
    					
    // Close the document.
    workdesk.Close();
    					
    // Close the project.
    project.Close();
    
    // Close the API.
    api.Close();
    See Also