Harness proD API Help
EPLAN.Harness.API.DataStructures.LibraryConnections Namespace / ActiveLibraryConnection Class / GetLibraryPartByGuidVer Method
Desired part's GUID.
Desired part's version (optional). If not specified, the highest revision of the highest version of the part is returned.
If true, the revision part of the version number is ignored. Optional parameter. The default value is false. If false, only the part with exactly the same version and revision is returned. This parameter is ignored if version is not specified.
Example
In This Topic
    GetLibraryPartByGuidVer Method
    In This Topic
    Get library part specified by GUID with option to specify part's version.
    Syntax
    public BaseLibraryPart GetLibraryPartByGuidVer( 
       string guid,
       PartVersion version,
       bool ignoreRevision
    )

    Parameters

    guid
    Desired part's GUID.
    version
    Desired part's version (optional). If not specified, the highest revision of the highest version of the part is returned.
    ignoreRevision
    If true, the revision part of the version number is ignored. Optional parameter. The default value is false. If false, only the part with exactly the same version and revision is returned. This parameter is ignored if version is not specified.

    Return Value

    A part with desired GUID and version.
    Exceptions
    ExceptionDescription
    The exception that is thrown when the project has no active library.
    Argument is invalid. The exception is thrown when a wrong argument is passed to the method or the setter of property.
    Example
    This example shows how to get a part from a connected library using GUID and version.
    // Open a project beforehand...
    Project project = ...
    
    // Part with specified GUID and version is unique. If not present in the library, null is returned.
    PartVersion version1 = new PartVersion("1.0.1");
    BaseLibraryPart partByGuidAndVersion1 = project.ActiveConnection.GetLibraryPartByGuidVer("be4259d972cc42c7aabc8eb339e7a60f", version1);
    
    // Part with specified GUID and version is unique. If ignoreRevision parameter is true, a part with the same major and minor version and highest revision is returned.
    PartVersion version2 = new PartVersion("1.0.1");
    BaseLibraryPart partByGuidAndVersion2 = project.ActiveConnection.GetLibraryPartByGuidVer("GUID", version2, true);
    partByGuidAndVersion2.Version.ToString(); // --> 1.0.5
    
    // If the version is not specified, a part with the highest version and revision is returned.
    BaseLibraryPart partByGuid = project.ActiveConnection.GetLibraryPartByGuidVer("be4259d972cc42c7aabc8eb339e7a60f");
    partByGuid.Version.ToString(); // --> 2.3.1
    See Also