Hide Table of Contents
Getting Started

Glossary Item Box

Writing a SolidWorks Simulation application typically involves:

  1. Instantiating a SolidWorks connection.

  2. Getting the COSMOSWorks object.

  3. Getting the model document object. Opening a document is required before trying to create a study.

  4. Using the study manager object to create a study.

  5. After creating a study, you can use the SolidWorks Simulation API to:

    • define materials

    • apply loads and restraints relevant to the study

    • apply contact features

    • apply mesh control

    • mesh the model

    • run the study

    • process the results

Error Handling

When appropriate, the Simulation API returns an error status code. Sometimes, directly returning a status code is not possible. When appropriate, the SolidWorks Simulation API returns an error code (a 32-bit value) which is 0 for success and non-0 for error.

SolidWorks Simulation 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 Simulation error code, but mappings back to the error code are provided. The Err.Description field contains a descriptive text field indicating the error. Better tracing of errors can be done through the Err object.

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


An executable (pidcollector.exe) is provided in install_dir\api to help you get the persistent IDs of selected entities.  

To use pidcollector.exe:

  1. Double-click pidcollector.exe while SolidWorks is running and a SolidWorks document is active. 
  2. Make a selection in the document and click Copy PIDSPIDPIDS clipboard in the PID Collector dialog.
  3. Paste the text copied to the clipboard into your application.
  4. Edit the pasted text as needed.
  5. Repeat steps 2 through 4 for each selection for which you want its PID.

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

Subject:   Feedback on Help Topics
Page:   Getting Started
*   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:


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

Web Help Content Version: API Help (English only) 2014 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.