0% found this document useful (0 votes)
3 views9 pages

API Help Overview

The document provides an overview of the API Help for a software product, detailing how to access and utilize the API for automation and customization. It includes instructions for navigating the API Help, using search functions, and understanding syntax conventions for various programming languages. Additionally, it emphasizes the importance of user feedback for improving the Help resources and clarifies the licensing terms for sample code provided within the API Help.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

API Help Overview

The document provides an overview of the API Help for a software product, detailing how to access and utilize the API for automation and customization. It includes instructions for navigating the API Help, using search functions, and understanding syntax conventions for various programming languages. Additionally, it emphasizes the importance of user feedback for improving the Help resources and clarifies the licensing terms for sample code provided within the API Help.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Welcome to API Help Page 1 of 9

Welcome to API Help

You can use a software product's API (Application Programming Interface) to:

l automate and customize the product.

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

Access and Navigation

Accessing 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.

To open context-sensitive SOLIDWORKS API Help from:


1. SOLIDWORKS VB.NET or C# macros opened in Visual Studio 2015:
1. In the IDE, select Help > Set Help Preference > Launch in Help Viewer.
2. Put your cursor on the interface, method, property, or delegate whose help topic you want displayed and press
the F1 key.
The associated help topic is displayed in Microsoft Help Viewer 2.2.
2. SOLIDWORKS VB.NET or C# applications opened in Visual Studio 2012:
1. In the IDE, put your cursor on the interface, method, property, or delegate whose help topic you want
displayed and press the F1 key.
2. If the associated help topic is not displayed, then select Tools > Options in the Help Viewer.
1. Select Online.
2. Select Try local first, then online or Try local only, not online.
3. Select Local Help.
4. Click OK.
5. Put your cursor on the interface, method, property, or delegate in the IDE again and press F1.
The associated help topic is displayed.
3. SOLIDWORKS VBA macros:
In the SOLIDWORKS Microsoft Visual Basic Integrated Developer Environment (IDE), put your cursor on the interface,
method, property, or event whose help topic you want displayed and press the F1 key. The associated help topic is
displayed.

IMPORTANT NAVIGATION CHANGES IN API HELP IN 2009 AND LATER

l Reference topics now use the name of the interface, not the object, as in earlier API Help systems.

So, in this Help, it is:

l IAdvancedSelectionCriteria not AdvancedSelectionCriteria,

l IAnnotation not Annotation,

l IAnnotationView not AnnotationView,

l IAssemblyDoc not AssemblyDoc, etc.

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

Navigating API Help

NOTE: The following information applies to API Help when accessed locally only.

l Index and Contents Tabs

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.

Wildcard Expressions (*, ?)

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.

Boolean Operators (AND, NEAR, NOT, OR)

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:

assembly AND mate AND relationship

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 Methods and arguments

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

Methods and arguments

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.

Visual Dim boolstatus As Boolean = false


Basic .NET
boolstatus = swModelExtension.SelectByID2("Point1", "SKETCHPPOINT",
.2, .3, 0, False, 0, Nothing, swSelectOptionDefault)
Visual Basic for Dim Result as Boolean
Applications Result = swModelExtension.SelectByID2("Point1", "SKETCHPOINT", .2,

file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 5 of 9

(VBA): .3, 0, False, 0, Nothing, swSelectOptionDefault)


C# bool boolstatus = false;
boolstatus = swModelExtension.SelectByID2("Point1", "SKETCHPOINT",
.2, .3, 0, false, 0, null, swSelectOptionDefault);
Unmanaged BOOL Result = FALSE;
C++ Dispatch: Result = swModelExtension.SelectByID2(_T("Point1"),_T
("SKETCHPOINT"), .2, .3, 0,0,0,0,swSelectOptionDefault);
Unmanaged VARIANT_BOOL Result = FALSE;
C++ COM: HRESULT hres = swModelExtension->SelectByID2(_T("Point1"),_T
("SKETCHPOINT"),.2,.3, 0,0,0,0,swSelectOptionDefault,&result);
C++/CLI bool bSelected = swModelExtension->SelectByID2(swBody->Name,
"SOLIDBODY", 0.0, 0.0, 0.0, true, 0, nullptr, (int)
swSelectOption_e::swSelectOptionDefault);

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:

Part.SetUnits swINCHES, swFRACTION, 16, 0, False

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.

Visual int docType = 0;


Basic .NET
docType = swModel.GetType();
Visual Basic for Dim docType As Long
Applications

file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 6 of 9

(VBA): docType = swModel.GetType


C# int docType = 0;
docType = swModel.GetType();
Unmanaged long docType = 0;
C++ Dispatch: docType = swModel .GetType();
Unmanaged long docType = 0;
C++ COM: HRESULT hres = swModel ->GetType( &docType );
C++/CLI swDocumentTypes_e nDocumentType;
nDocumentType = (swDocumentTypes_e)swModel->GetType();

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).

Visual Dim swFace as Face2 = Nothing


Basic .NET
swFace = swBody.GetFirstFace
Visual Basic for Dim swFace As Object
Applications Set swFace = swBody.GetFirstFace
(VBA):

C# Face2 swFace = null;


swFace = (Face2) swBody.GetFirstFace();
Unmanaged IDispatch* faceDisp = NULL;
C++ Dispatch: faceDisp = swBody.GetFirstFace();
IFace2 swFace(faceDisp);
Unmanaged LPFACE2 swFace = NULL;
C++ COM: HRESULT hres = swBody->IGetFirstFace( &swFace );
C++/CLI IFace2^ swFace = nullptr;
swFace = (IFace2^)swBody->GetFirstFace();
- or -
IFace2^ swFace = nullptr;
swFace = swBody->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.

Visual Basic .NET get: featName = swFeat.Name

file:///C:/Users/OBEDIENCE/AppData/Local/Temp/~hhFA49.htm 2/1/2025
Welcome to API Help Page 7 of 9

set: swFeat.Name = featName


Visual Basic for get: featName = swFeat.Name
Applications
(VBA): set: swFeat.Name = featName
C# get: featName = swFeat.Name;
set: swFeat.Name = featName;
Unmanaged C++ get: featName = swFeat.GetName();
Dispatch:
set: swFeat.SetName(featName);
Unmanaged C++ get: hres = swFeat->get_Name(&featName);
COM:
set: hres = swFeat->put_Name(featName);
C++/CLI get: featName = swFeat->Name;
set: swFeat->Name = featName;

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

Additional resources for APIs and product-specific information are:

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.

SOLIDWORKS PDM Professional


Start the SOLIDWORKS PDM Professional Administration tool, log into a SOLIDWORKS PDM vault as admin,

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

Contacting API Support

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

The API support e-mail address is [email protected].


An API is a thin layer over the user interface. Thus, if there is a problem in the API, it often exists in the user interface. If you
can reproduce the problem in the user interface, report the problem to SOLIDWORKS User-interface Technical Support.
When the problem is fixed in the user interface, then the fix is automatically applied to the API.

Information to include in your e-mail message to API Support

l Your contact information .

l Your product serial or license number.

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 All API methods, properties, and events related to your problem.

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.

l All test files (SOLIDWORKS documents and so on).

l Graphics driver details (if the problem is graphics related).

l Operating-system details (if you suspect the problem is operating-system related).

l Source code for your project as per these guidelines.

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

You might also like