API Help Overview
API Help Overview
You can use a software product's API (Application Programming Interface) to:
l write applications that add functionality to the product, typically referred to as add-in applications.
Each product's API contains multiple functions that you can call from Visual Basic for Applications (VBA), VB.NET, Visual C#,
Visual C++ 6.0 , and Visual C++/CLI. These functions provide direct access to product's functionality.
API Help is available on the Web and locally. See Accessing API Help in Access and Navigation.
Use the Send comments link located in the upper-right corner of a reference topic to report errors and omissions in the
Help. The subject line of the mail message sent to API Help Feedback will automatically contain the name of the reference
topic that you are reading. If you have feedback about a topic without a Send Comments link, then send your feedback to
[email protected]. Your feedback is important because it will help Dassault Systèmes SolidWorks Corporation
improve the Help, which will hopefully benefit you. Please continue to send functionality related questions about any of the
APIs to SOLIDWORKS API Support.
NOTE: All of the sample code supplied is provided on an as-is basis, and is only intended to demonstrate ways of using an
API. No representations or warranties are made regarding these samples. Any licensed user of an API is free to use any or all
of these samples in connection with building applications related to that API, and is granted a royalty-free, non-exclusive
license for these samples, or parts thereof. Intellectual property rights of the samples remain with SOLIDWORKS. Any
confidentiality provisions of the applicable product license apply to the samples.
API Help
API Help is available on the Web or locally. To enable your access to API Help on the Web, select Help > Use SOLIDWORKS
Web Help. A check mark indicates that API Help is enabled and accessible on the Web.
NOTES:
l API Help is updated for every service pack; however, the web version of API Help is only updated for service packs
SP0, SP1, and SP5. If you want the most up-to-date version of API Help for service pack SP2, SP3, or SP4, use the
latest local version of API Help.
l The local version of API Help is not automatically installed with SOLIDWORKS service packs. Get the latest local
version of API Help that includes updates for the functionality contained in a given service pack from the
SOLIDWORKS Customer Portal:
1. Open www.solidworks.com.
2. Log into the SOLIDWORKS Customer Portal.
3. Click Downloads and Updates.
4. On the SOLIDWORKS tab:
1. At the top, select the version of SOLIDWORKS whose API Help you want to download.
2. At the bottom, click the product link for the service pack whose API Help you want to download.
5. In the SOLIDWORKS Download EULA page, click the English button and click Accept Agreement &
Continue.
6. At the bottom of the Download and Install page, click the download, unzip, and install all the files
link.
7. Select a version in the Upgrading from Service Pack list, select the product in the SOLIDWORKS
Product list, and click Continue.
8. Click SOLIDWORKS Help in the Step 4 - Required updates table.
9. After swHelpEnglish.exe downloads, double-click it to open the installer dialog.
10. Specify a local directory and click OK to copy the files to it.
11. Navigate to the location you specified to copy the files or to the default location,
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 2 of 9
C:\SWDist\swHelpEnglish\Files\api.
12. Copy all of the files in this folder to your SOLIDWORKS installation \api folder so that the just-
downloaded version of API Help is available in a running session of SOLIDWORKS.
l Reference topics now use the name of the interface, not the object, as in earlier API Help systems.
All interface, method, properties, and delegate topics contain links to their corresponding Visual Basic for
Applications (VBA) object, method, properties, and event topics. Additionally each Visual Basic for Applications
(VBA) object topic includes that object's object model in graphical format, if an object model exists. If an object
model does not exist, then the object's topic is blank.
l The SOLIDWORKS interfaces are no longer categorized by functionality on the Contents tab. Instead, they appear
in alphabetical order in their respective interop assembly namespace book. If you prefer to locate SOLIDWORKS
reference (i.e., interface, method, property, and delegate topics) topics categorized by functionality, then open
the Functional Categories topic in the SOLIDWORKS APIs book, which is located in the SOLIDWORKS API Help
book. The SolidWorks.Interop.sldworks Namespace book contains the majority of the reference topics for the
SOLIDWORKS interfaces.
l Topics for obsolete interfaces, methods, properties, and delegates are not accessible from the Contents tab;
however, they are accessible using the Index and Search tabs. Always read the description at the top of a topic.
A link to the current version of a topic appears in the description. Descriptions for obsolete topics have
intentionally been omitted.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 3 of 9
NOTE: The following information applies to API Help when accessed locally only.
If you are looking for specific functionality, but do not know the name of the function (interface, method, property,
delegate, or enumerator), the quickest way to locate the function is to use the Index tab.
Index tab
Click the Index tab and type in the first few letters of the function whose topic you want displayed. For example to
find the assembly interface topic, you can type assemb and Assemblies (see also IAssemblyDoc Interface) is
selected. Double-click Assemblies (see also IAssemblyDoc Interface). Select IAssemblyDoc Interface and click
Display in the Topics Found dialog.
Contents tab
You can also peruse the table of contents. Click the Contents tab, click a book to expand it, and examine its topics.
API reference topics appear by product in their interop assembly namespace book or books.
All reference (interface, method, property, and delegate) topics include breadcrumbs near the top of the topic. These
breadcrumbs can help you determine which product's topic you are reading. Additionally the name of a method's or
property's interface appears enclosed in parentheses after the name of the method or property at the top of the topic
and at the end of the breadcrumb.
l Search Tab
If you cannot find the function that you want using the Index or Contents tabs, you can use the Search tab.
Type a word or phrase on the Search tab to see a list of topics that contain that word or phrase. For example, type
tangent edges and click List Topics on the Search tab to see the topics that contain that exact or similar phrase. To
reduce the number of topics found, clear the Match similar words (if selected) and select the Search titles only (if
not selected) check boxes, which appear after the list. By default, the search results are ranked by number of
occurrences of the word or phrase in the topic. You can alphabetize the search results by clicking Title.
You can also use wildcard expressions and boolean operations in your search word or phrase.
NOTE: If you specify an object by name in your search (e.g., Annotation), then the interface topic will appear in the
search results (e.g., IAnnotation), not the object topic. Object topics do not appear in the search results; only the
interface topics.
You can type the exact name of the function or you can use an * (asterisk) in your search expression to locate all of
the topics that contain the search expression. For example, type noti* to locate all of the topics containing the word
notify, notifies, notification, notice, and so on.
To locate all of the topics that contain just the word notify, type notif?. The ? (question mark) indicates to search for
the specified expression string plus one character.
NOTE: The * and ? characters can appear at the beginning, embedded within, or at the end of a search
expression. However, they cannot be the only character in the search expression.
You can use Boolean operators in the search expression. For example, if you are trying to find the SOLIDWORKS
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 4 of 9
method that adds a mate condition between two assembly components, click the Search tab and type the following
keywords and the Boolean operator AND:
This search expression locates the IAssemblyDoc Interface Members, IAssemblyDoc Interface Methods,
AddMate3 Method (IAssemblyDoc), EditMate2 Method (IAssemblyDoc), and, of course, this topic.
Other Boolean operators that you can use in your search string are:
l NEAR – Locate all of the topics that contain the specified terms, close together.
l NOT – Locate all of the topics that contain the term specified before NOT, then exclude all of the topics that contain
the term specified after NOT
l OR – Locate all of the topics that contain any of the specified terms.
API Help
Syntax Conventions
See Also
This topic explains the syntax conventions used with the API Help:
l Notation
l Return values
l Interfaces
l Properties
l Availability links
Notation
All SOLIDWORKS and add-in API functions support the COM interface. If you are using COM, the SOLIDWORKS or add-in API
function returns an HRESULT, and any additional return values are passed by reference as arguments.
Back to top
The following syntax uses the SOLIDWORKS method, IModelDocExtension::SelectByID2, which is a function that returns a
BOOLEAN value. It passes nine arguments to the function.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 5 of 9
NOTE: The return value in the Visual Basic (Usage) section in the Help is always shown as value. Because some methods
and properties contain an argument named Value, SOLIDWORKS recommends that you rename the return value variable
value to something meaningful to avoid an error in your code and for clarity.
The next example uses the SOLIDWORKS method, IDrawingDoc::EditSheet, which is a subroutine which returns nothing
(void). The method accepts no arguments.
Visual
Basic .NET swDrawing.EditSheet()
Visual Basic for
Applications
(VBA): swDrawing.EditSheet (see the Note below this table)
C# swDrawing.EditSheet();
Unmanaged
C++ Dispatch: swDrawing.EditSheet();
Unmanaged HRESULT hres = swDrawing->EditSheet();
C++ COM:
C++/CLI swDrawing->EditSheet();
NOTE: Some methods are subroutines (that return nothing (void)) that also pass arguments. The VBA syntax for those
methods is slightly different, despite what the Visual Basic for Applications (VBA) Syntax section of the help indicates. The
help shows parentheses in the method signatures of all VBA methods. In practice, parentheses are not used in the VBA
method signature of subroutines that return nothing. For example, IModelDoc2::SetUnits is a subroutine that returns nothing
but passes arguments. The correct way to call IModelDoc2::SetUnits in VBA:
Back to top
Return values
The following syntax uses the SOLIDWORKS method, IModelDoc2::GetType, which is a subroutine that returns a long value.
This function takes no arguments. Instead, it uses the current IModelDoc2 object and returns its type.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 6 of 9
Back to top
Interfaces
Some functions have different versions of syntax. A function has multiple interfaces only when required. Always check the
See Also link near the bottom of topic to see if a function has multiple interfaces (e.g., IBody2::GetFirstFace and
IBody2::IGetFirstFace).
The Dispatch interface returns a Dispatch pointer, while the COM interface returns an LPFACE2 pointer. The COM interface
uses object pointers instead of Dispatch pointers and pointers instead of VARIANT SafeArrays. Because the argument types
are different, any API function that handles objects or arrays has two distinct interfaces, one for COM and one for Dispatch.
Back to top
Properties
The following syntax uses the SOLIDWORKS property IFeature::Name to get and set the name of a feature.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 7 of 9
Back to top
Availability links
The Availability links appearing at the bottom of a method, property, and delegate topic identifies the release in which the
method, property, or delegate was introduced. Topics in the API Help lacking Availability links indicate that the method,
property, or delegate was introduced prior to the SOLIDWORKS 98Plus release.
Back to top
API Help
Obsolete APIs
APIs are continually enhanced. 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. For example, the
method IEntity::Select4 superseded IEntity::Select3, which superseded IEntity::Select2, etc. In this example,
IEntity::Select3, IEntity::Select2 and IEntity::Select are obsolete APIs.
It is recommended that you use the newest APIs in your code, and, whenever possible, update your existing code to use the
newest APIs.
Topics for obsolete interfaces, methods, properties, and delegates are not accessible from the Contents tab; however, they
are accessible from the Index and Search tabs. Always read the description at the top of a topic. A link to the current version
of a topic appears in the description. Descriptions for obsolete topics published prior to the SOLIDWORKS 2009 SP0 release
have intentionally been omitted.
API Help
Resources
SOLIDWORKS
Start the SOLIDWORKS software and click Help > SOLIDWORKS Help.
SOLIDWORKS Costing
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and open the SOLIDWORKS Costing
book.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 8 of 9
expand the vault, right-click Add-ins, and click Programmer's Reference Guide.
FeatureWorks
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, expand the Features book, and open
the FeatureWorks book.
eDrawings
Start the eDrawings software and click Help > eDrawings Help Topics.
SOLIDWORKS Routing
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and open the Routing book.
SOLIDWORKS Simulation
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and open the Simulation book.
SOLIDWORKS Sustainability
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and expand the Sustainability
Products book, and open the SOLIDWORKS Sustainability book.
SOLIDWORKS Toolbox
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and open the Toolbox book.
SOLIDWORKS Utilities
Start the SOLIDWORKS software, click Help > SOLIDWORKS Help, and open the SOLIDWORKS Utilities
book.
API Help
It is our goal to provide the best support possible for the APIs. Understanding how this support works, and the type of
information we need to assist you, can help us solve your problems as quickly and efficiently as possible.
API Support
l A description of your problem. Please send each problem in a separate e-mail message to ensure appropriate tracking
of the problem.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 9 of 9
l Product version, including service pack. If your problem is a regression, report the last version in which your code
worked correctly, including the service pack number.
NOTE: Whenever possible, avoid using obsolete APIs in your code; instead, update your code to use the most recent
APIs to see if that fixes your problem.
file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025