US$0.00
0

SOLIDWORKS PDM API TIP: Writing Add-ins with Version-Specific APIs

When writing an add-in for SOLIDWORKS PDM, it is essential to consider compatibility across different versions of the software. Some API calls introduced in newer versions may not be available in older versions, potentially causing runtime errors for clients using older systems, which is why writing add-ins with version-specific APIs becomes so important.

Writing Add-ins with Version-Specific APIs

Scenario

Suppose your add-in uses an API feature introduced in SOLIDWORKS PDM 2022, but some clients are still using SOLIDWORKS PDM 2018. To ensure compatibility, you can programmatically check the PDM version installed on the client’s machine before calling the new API.

Solution: Use the GetVersion Method

The GetVersion method allows you to retrieve the major and minor version numbers of the installed SOLIDWORKS PDM Professional. Based on the version, your code can decide whether to execute the new API call or fall back to an alternative logic for older versions.

Implementation

Here is an example in Visual Basic:

Sub CheckPDMVersionAndCallAPI()
    Dim vault As IEdmVault5 = New EdmVault5()
    Dim majorVersion As Integer = 0
    Dim minorVersion As Integer = 0
    
    ' Get the installed PDM version
    vault.GetVersion(majorVersion, minorVersion)
    
    If majorVersion >= 2022 Then
        ' Call the new API method
        CallNewAPIFeature()
    Else
        ' Fallback logic for older versions
        MsgBox("The new API is not supported on this version of SOLIDWORKS PDM. Please upgrade to 2022 or later.")
    End If
End Sub

Sub CallNewAPIFeature()
    ' Implement the new API feature here
    MsgBox("Calling the new API feature available in SOLIDWORKS PDM 2022.")
End Sub

This approach ensures your add-in remains robust and user-friendly, even in environments with mixed PDM versions, highlighting the importance of writing add-ins with version-specific APIs.

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop
    ×