Hide Table of Contents
Getting Started

Glossary Item Box

This topic contains the following information:

Application Basics

Writing a SOLIDWORKS Workgroup PDM API application typically involves:

  1. Instantiating a SOLIDWORKS Workgroup PDM connection and logging in.

    When you connect and log in to SOLIDWORKS Workgroup PDM via the API, the SOLIDWORKS Workgroup PDM API object model is implemented as a snapshot of what is in the vault at that time. If the state of the vault changes either through the user interface or the API (for example, by a check in, the creation of a new project, the addition of a note, and so on), you must call IPDMWConnection::Refresh to ensure that subsequent API calls return the most current data.

    IMPORTANT: Because IPDMWConnection::CheckIn is dependent on pdmworks_libFNP.dll, you must ensure that your application can find this DLL. The simplest way for your application to find pdmworks_libFNP.dll is to add its location to the PATH environmental variable. See Microsoft Corp's Dynamic-Link Library Search Order for details.

    SOLIDWORKS Workgroup PDM API contains several methods that change the state of the SOLIDWORKS Workgroup PDM vault; however, most of the exposed object model contains read-only properties. Therefore, a typical SOLIDWORKS Workgroup PDM application displays and analyzes vault data rather than updates it.

  2. Getting and reading the various VB-compatible collections that represent:

    • projects,

    • documents in those projects, and

    • those projects' configurations, references, and other properties.

  3. Logging out.

The SOLIDWORKS Workgroup PDM API exposes VB-compatible collections for easy iteration of similar objects using the For Each...Next statement. For example, to iterate over the set of documents in a vault, you could use the following code fragment:

Dim connection As PDMWConnection

Dim allDocs As PDMWDocuments

Dim document As PDMWDocument

 

Sub main()

Set connection = CreateObject("PDMWorks.PDMWConnection")

connection.Login "pdmwadmin", "pdmwadmin", "vault_server_name"

Set allDocs = connection.documents

 

For Each document In allDocs

     'Access each PDMWDocument here

Next

connection.Logout

 

End Sub

Back to top

Error Handling

When appropriate, the SOLIDWORKS Workgroup PDM API returns an error status code, for example, when performing IPDMWProperties::Update. Sometimes, directly returning a status code is not possible, for example, when retrieving a document via IPDMWConnection::GetSpecificDocument.

If an error status is returned, it is in the form of a SOLIDWORKS Workgroup PDM error code (a 32-bit value). This code returns 0 for success and non-0 for error.

SOLIDWORKS recommends that you use the intrinsic Visual Basic Err object to get rich error information. In this case, the Err.number field does not correspond directly to the SOLIDWORKS Workgroup PDM error code, but mappings back to the error code are provided. The Err.Description field is filled with a descriptive text field indicating the error. In this way, better tracing of errors can be done through the Err object.

In Visual Basic 5.0, error handling can easily be accomplished with the On Error Resume Next statement. For example:

On Error Resume Next

Dim conn

Set conn = CreateObject(PDMWorks.PDMWConnection)

conn.Login user, incorrect password, vault

Err.number contains the error number

Err.description contains the appropriate error description

 

Back to top

Obsolete APIs

SOLIDWORKS Workgroup PDM is continually enhancing its APIs. In most instances, when an existing API is superseded by a new API, the new API has the same name as the existing API followed by a number. A higher number indicates a more recent API.

Superseded APIs are not supported. Help topics for superseded APIs are marked as obsolete.

SOLIDWORKS recommends that you use the newest APIs in your code, and, whenever possible, update your existing code to use the newest APIs.

 

Back to top



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Getting Started
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.