apihelp
apihelp
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,
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.
IAdvancedSelectionCriteria not
AdvancedSelectionCriteria,
IAnnotation not Annotation,
IAnnotationView not AnnotationView,
IAssemblyDoc not AssemblyDoc, etc.
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
Search Tab
If you cannot find the function that you want using the
Index or Contents tabs, you can use the Search tab.
This topic explains the syntax conventions used with the API Help:
Notation
Methods and arguments
Return values
Interfaces
Properties
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
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.
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
Visual Basic
for Dim docType As Long
Applications docType = swModel.GetType
(VBA):
int docType = 0;
C#
docType = swModel.GetType();
swDocumentTypes_e nDocumentType;
C++/CLI
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 Basic
for Dim swFace As Object
Applications Set swFace = swBody.GetFirstFace
(VBA):
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
for get: featName = swFeat.Name
Applications set: swFeat.Name = featName
(VBA):
Unmanaged featName =
get:
C++ swFeat.GetName();
Dispatch: set:
swFeat.SetName(featName);
hres = swFeat-
Unmanaged get: >get_Name(&featName);
C++ COM: set: hres = swFeat-
>put_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.
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
NOTES: