0% found this document useful (0 votes)
2 views

api_fundamentals_training_course

The document provides an overview of the SOLIDWORKS API Fundamentals course, including its prerequisites, course length, and design philosophy. It covers various topics such as macro recording, API object interfaces, and system options, along with exercises for practical application. Additionally, it includes legal disclaimers regarding software use and rights for U.S. government acquisitions.

Uploaded by

fabio.tiburi
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)
2 views

api_fundamentals_training_course

The document provides an overview of the SOLIDWORKS API Fundamentals course, including its prerequisites, course length, and design philosophy. It covers various topics such as macro recording, API object interfaces, and system options, along with exercises for practical application. Additionally, it includes legal disclaimers regarding software use and rights for U.S. government acquisitions.

Uploaded by

fabio.tiburi
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/ 10

SOLIDWORKS

API Fundamentals

Dassault Systèmes SolidWorks Corporation


175 Wyman Street
Waltham, MA 02451 U.S.A.
© 1995-2022, Dassault Systemes SolidWorks Restricted Rights
Corporation, a Dassault Systèmes SE company, This clause applies to all acquisitions of Dassault
175 Wyman Street, Waltham, Mass. 02451 USA. Systèmes Offerings by or for the United States
All Rights Reserved. federal government, or by any prime contractor or
The information and the software discussed in this subcontractor (at any tier) under any contract,
document are subject to change without notice grant, cooperative agreement or other activity
and are not commitments by Dassault Systemes with the federal government. The software,
SolidWorks Corporation (DS SolidWorks). documentation and any other technical data
No material may be reproduced or transmitted in provided hereunder is commercial in nature and
any form or by any means, electronically or developed solely at private expense. The Software
manually, for any purpose without the express is delivered as "Commercial Computer Software"
written permission of DS SolidWorks. as defined in DFARS 252.227-7014 (June 1995)
or as a "Commercial Item" as defined in FAR
The software discussed in this document is 2.101(a) and as such is provided with only such
furnished under a license and may be used or rights as are provided in Dassault Systèmes
copied only in accordance with the terms of the standard commercial end user license agreement.
license. All warranties given by DS SolidWorks Technical data is provided with limited rights only
as to the software and documentation are set forth as provided in DFAR 252.227-7015 (Nov. 1995)
in the license agreement, and nothing stated in, or or FAR 52.227-14 (June 1987), whichever is
implied by, this document or its contents shall be applicable. The terms and conditions of the
considered or deemed a modification or Dassault Systèmes standard commercial end user
amendment of any terms, including warranties, in license agreement shall pertain to the United
the license agreement. States government's use and disclosure of this
software, and shall supersede any conflicting
contractual terms and conditions. If the DS
For a full list of the patents, trademarks, and third- standard commercial license fails to meet the
party software contained in this release, please go United States government's needs or is
to the Legal Notices in the SOLIDWORKS inconsistent in any respect with United States
documentation. Federal law, the United States government agrees
to return this software, unused, to DS. The
following additional statement applies only to
acquisitions governed by DFARS Subpart 227.4
(October 1988): "Restricted Rights - use,
duplication and disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c)(l)(ii) of the Rights in Technical Data and
Computer Software clause at DFARS 252-227-
7013 (Oct. 1988)."

In the event that you receive a request from any


agency of the U.S. Government to provide
Software with rights beyond those set forth above,
you will notify DS SolidWorks of the scope of the
request and DS SolidWorks will have five (5)
business days to, in its sole discretion, accept or
reject such request. Contractor/ Manufacturer:
Dassault Systemes SolidWorks Corporation, 175
Wyman Street, Waltham, Massachusetts 02451
USA.

Document Number: PMT2315-ENG


Contents

Introduction
About This Course . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Course Length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Course Design Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Using this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
About the Training Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Conventions Used in this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Windows® 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Use of Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Graphics and Graphics Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Color Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
More SOLIDWORKS Training Resources. . . . . . . . . . . . . . . . . . . . . . 5
Local User Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Option Explicit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Choosing Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
API Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
SOLIDWORKS Constants Type Library . . . . . . . . . . . . . . . . . . . . 8

i
Contents SOLIDWORKS

Macro Recording Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


SOLIDWORKSAPI Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
API Object Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Favorites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Understanding API Interface Member Descriptions . . . . . . . . . . 12
Lesson 1:
Using the Macro Recorder
Macro Recording . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Macro Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Understanding How Macro Code Works . . . . . . . . . . . . . . . . . . . . . . 21
Variable Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Entry Point Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
SOLIDWORKS Application Object. . . . . . . . . . . . . . . . . . . . . . . 21
SOLIDWORKS Document Object . . . . . . . . . . . . . . . . . . . . . . . . 21
SOLIDWORKS API Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Procedure End. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Understanding How to Call Members on API Interfaces . . . . . . . . . . 22
Passing Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Cleaning Up Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Commenting Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Debugging Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Adding Forms to a Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Exercise 1: Recording a Macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Exercise 2: Adding Macro Code to a VBA Button Control . . . . . . . . 39
Exercise 3: Adding User Input Fields on a VBA Form . . . . . . . . . . . 43
Lesson 2:
The API Object Model
SOLIDWORKS API Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Visual Basic Automatic Type Casting . . . . . . . . . . . . . . . . . . . . . 47
Application Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
SldWorks Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
SOLIDWORKS 20xx Type Library . . . . . . . . . . . . . . . . . . . . . . . 49
IntelliSense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Early vs. Late Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Case Study: Connecting to New Documents . . . . . . . . . . . . . . . . . . . 52
ModelDoc2 Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
ModelDocExtension Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
PartDoc Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
AssemblyDoc Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
DrawingDoc Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Case Study: Connecting to Existing Documents . . . . . . . . . . . . . . . . 70
Exercise 4: Working with New Documents . . . . . . . . . . . . . . . . . . . . 78
Exercise 5: Working with Existing Documents . . . . . . . . . . . . . . . . . 80

ii
SOLIDWORKS Contents

Lesson 3:
Setting System Options and Document Properties
User Preferences - System Options . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Setting Checkboxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Setting Textboxes with Integers . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Setting Textboxes with Doubles . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Setting Textboxes with String Values . . . . . . . . . . . . . . . . . . . . . 88
Setting Listboxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Setting Radio Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Setting Slider Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
User Preferences - Document Properties . . . . . . . . . . . . . . . . . . . . . . 91
Locating the Correct APIs and Enumeration Values. . . . . . . . . . . . . . 92
UserPreference Tables For System Options,
Document Properties and Menu Items . . . . . . . . . . . . . . . . . . . . . . . . 94
Exercise 6: Change Multiple System Options . . . . . . . . . . . . . . . . . . 95
Exercise 7: Change Multiple Document Properties . . . . . . . . . . . . . . 97
Lesson 4:
Automating Part Design
Case Study: Automation Tool for Parts . . . . . . . . . . . . . . . . . . . . . . 100
Setting Material. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Creating the Sketch Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Adding Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Selection on Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Creating the Sketch Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Creating Extruded Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Enabling Contour Selection for the Extrusion . . . . . . . . . . . . . . 106
Creating Revolved Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Standard Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
View Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Sketch Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Sketch Tools Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Features Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Sketch Relations Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Reference Geometry Commands . . . . . . . . . . . . . . . . . . . . . . . . 111
Exercise 8: Automating the Part Creation Process . . . . . . . . . . . . . . 112

iii
Contents SOLIDWORKS

Lesson 5:
Assembly Automation
Case Study: Automation Tool for Assemblies . . . . . . . . . . . . . . . . . 116
Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Creating MathTransforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
The Transformation Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Activating Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Invisible Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Object Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Establishing the Curve and Edge Collections. . . . . . . . . . . . . . . 121
Establishing the Face Collection. . . . . . . . . . . . . . . . . . . . . . . . . 122
Getting Adjacent Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Establishing the Points Collection . . . . . . . . . . . . . . . . . . . . . . . 124
Getting Curve Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Adding and Mating the Knobs to the Chassis. . . . . . . . . . . . . . . 125
Adding Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Adding Mates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Exercise 9: Adding Components . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Lesson 6:
Drawing Automation
Case Study: Automating Drawing Creation . . . . . . . . . . . . . . . . . . . 134
Getting Configuration Names . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Creating Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Creating Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Traversing Drawing Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Inserting Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Saving Drawings in Different Formats . . . . . . . . . . . . . . . . . . . . 144
Drawing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Annotation Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Layer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Line Format Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Exercise 10: Drawing Automation . . . . . . . . . . . . . . . . . . . . . . . . . . 147

iv
SOLIDWORKS Contents

Lesson 7:
Selection and Traversal Techniques
Case Study: Programming With a Selected Object . . . . . . . . . . . . . 152
SelectionManager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Accessing the Selection Manager . . . . . . . . . . . . . . . . . . . . . . . . 153
Counting Selected Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Accessing Selected Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Getting Selected Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Getting Feature Type Names . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Feature Data Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Accessing the Feature Data Object . . . . . . . . . . . . . . . . . . . . . . . 155
Accessing Selections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Releasing Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Modifying Feature Data Properties. . . . . . . . . . . . . . . . . . . . . . . 157
Modify the Object Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
The SOLIDWORKS BREP Model. . . . . . . . . . . . . . . . . . . . . . . . . . 158
Traversing Topology and Geometry. . . . . . . . . . . . . . . . . . . . . . 159
Case Study: Body and Face Traversal . . . . . . . . . . . . . . . . . . . . . . . 159
Returning a List of Body Pointers . . . . . . . . . . . . . . . . . . . . . . . 161
Face Material Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Case Study: Feature Manager Traversal . . . . . . . . . . . . . . . . . . . . . . 164
Traversing the FeatureManager Design Tree from the Top . . . . 165
Displaying Feature Names and Types . . . . . . . . . . . . . . . . . . . . 165
Setting Feature Suppression . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Setting Feature UI State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Obtaining a Feature by FeatureManager Design Tree Position . 169
Exercise 11: Handling Preselection 1 . . . . . . . . . . . . . . . . . . . . . . . . 170
Exercise 12: Handling Preselection 2 . . . . . . . . . . . . . . . . . . . . . . . . 172
Exercise 13: Traversing the FeatureManager Design Tree . . . . . . . 174

v
Contents SOLIDWORKS

Lesson 8:
Adding Custom Properties and Attributes
Case Study: Custom Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Adding Custom Properties to a SOLIDWORKS Document . . . 179
CustomPropertyManager Object . . . . . . . . . . . . . . . . . . . . . . . . 179
Setting and Getting Custom Property Values . . . . . . . . . . . . . . . 181
Getting Custom Property Names . . . . . . . . . . . . . . . . . . . . . . . . 182
Getting the Custom Property Count . . . . . . . . . . . . . . . . . . . . . . 182
Case Study: Configurations With Custom Properties. . . . . . . . . . . . 184
Returning Mass Properties From a SOLIDWORKS Model. . . . 186
Using the API to Return the Mass Properties . . . . . . . . . . . . . . . 186
MassProperty2 Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Case Study: File Summary Information . . . . . . . . . . . . . . . . . . . . . . 189
Adding Summary Information . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Case Study: Document Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Naming Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
The Attribute Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
AttributeDef Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Attribute Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Parameter Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Case Study: Face Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Finding the Cylindrical Faces and Attaching Attributes . . . . . . 196
Displaying Callouts in the Model View . . . . . . . . . . . . . . . . . . . 198
Callout Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Creating the CNC Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Types of Attribute Traversal. . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
A Final Word about Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Exercise 14: Adding Mass Properties as Custom Properties . . . . . . 204
Exercise 15: Adding Attributes to Edges . . . . . . . . . . . . . . . . . . . . . 206
Lesson 9:
The SOLIDWORKS API SDK
The API SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Installing the SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Case Study: Creating a VB.NET Add-In . . . . . . . . . . . . . . . . . . . . . 214
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Comparing Addin DLLs and Stand-Alone Executables. . . . . . . 218
Loading and Running an Add-in Application. . . . . . . . . . . . . . . 219
Case Study: Creating a C# Add-in . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Case Study: C++ Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Compiling a C++ Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Loading the C++ Add-In. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Debugging the C++ Add-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Choosing a Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . 234

vi
SOLIDWORKS Contents

Lesson 10:
Customizing the SOLIDWORKS User Interface
Case Study: Customizing the UI With VB.NET. . . . . . . . . . . . . . . . 236
Debugging the DLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Debugger Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Understanding The Add-in Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Importing Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
The Add-in Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Understanding the GUID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Connecting to SOLIDWORKS. . . . . . . . . . . . . . . . . . . . . . . . . . 245
Bidirectional Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Setting Callback Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Custom Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Custom Command Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Command Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Command Tab Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Command Tab Box Commands . . . . . . . . . . . . . . . . . . . . . . . . . 253
Creating and Adding Custom Toolbars to an Add-in . . . . . . . . . 256
Creating the Toolbar Bitmaps. . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Adding Toolbar Bitmaps to a VB.NET Solution . . . . . . . . . . . . 257
The Bitmap Handler Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Adding Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Property Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
PropertyPage Members. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
SldWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
UserPMPage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
SldWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
ppage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
PropertyManager-Page2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
PropertyManager-Page2Handler8 . . . . . . . . . . . . . . . . . . . . . . . 263
Creating a PropertyManager Page . . . . . . . . . . . . . . . . . . . . . . . 264
Property Page Groups and Controls . . . . . . . . . . . . . . . . . . . . . . . . . 266
Adding Group Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Group and control IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Adding Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Adding Picture Labels to Controls . . . . . . . . . . . . . . . . . . . . . . . 270
Removing Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Other Areas of Customization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Custom Status Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Custom Pop-up Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Custom ModelView Windows . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Exercise 16: Implement a New Menu. . . . . . . . . . . . . . . . . . . . . . . . 277
Exercise 17: Implement Toolbar Buttons . . . . . . . . . . . . . . . . . . . . . 282
Exercise 18: Implement Controls on a Property Manager Page . . . . 287

vii
Contents SOLIDWORKS

Lesson 11:
Notifications
Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Notifications in VBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Case Study: Simple Notification. . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
The Class Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Case Study: Using Notifications in .NET. . . . . . . . . . . . . . . . . . . . . 296
The AddHandler Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
The AddressOf Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
The Event Handler Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
The Document Event Handler Class. . . . . . . . . . . . . . . . . . . . . . 301
Attaching the DocumentEvent Handlers . . . . . . . . . . . . . . . . . . 303
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Polymorphism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
The Derived Event Handler Classes . . . . . . . . . . . . . . . . . . . . . . 307
The DocView Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Detaching the Document and Model View Event Handlers. . . . 314
Detaching the SOLIDWORKS Event Handlers . . . . . . . . . . . . . 320
Interfaces That Support Notifications. . . . . . . . . . . . . . . . . . . . . 322
Exercise 19: Handling Events Using the Add-in Wizard . . . . . . . . . 323
Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Appendix A:
Examples
Macro Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
Batch Conversion 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Batch Conversion 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Assembly Traversal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

viii

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy