Welcome
Getting Started
Overview
Types of SolidWorks API Applications
SolidWorks API Object Model and Class Hierarchy
Programming with the SolidWorks API
Add-ins
API Dependent on SolidWorks Being Visible
Arrays
Attributes Imported from ACIS SAT Files
Bitmasks
Block Definitions and Block Instances
Bodies in Body Folders
BOOL and VARIANT_BOOL
Bounding Box and Note Text
COM vs. Dispatch
CommandManager and CommandGroups
Components, Configurations, and Suppression States
Compound Note
ComVisibleAttribute in VSTA macros
Controls, Visual Basic 6.0, and Windows XP
Double Arrays and Integer Pairs
Drawing Views and Model Entities
Early and Late Binding
Events
Features of Components
Helper Functions
Hole Wizard Features and Objects
IDispatch Object Arrays as Input in .NET
Implementation Guidelines
Import and Export File Options
In-process Methods
Instantiate ActiveX Controls as Tabs
Interface Pointers
Keystrokes and Accelerator Keys
Library Features and Objects
Lightweight Components
Line Attributes for View::GetPolyLinesAndCurves
Line Weights
Long vs. Integer
Macro Features
Manipulators
Mass Properties
Multibody Parts
Option Explicit Statement
Partition Rollback and API Handles
Persistent Reference IDs
Presentation Transforms
PropertyManager Pages
.NET Interop Assemblies
Quick Tips and Bubble ToolTips
Return Values
SafeArrays
Selection Criteria
Selection Lists
Selections that Define Features
Setup Project to Distribute SolidWorks Add-in
Smart Pointers
SolidWorks Objects
Sorting Tables
SQLite
STL Container Classes and Smart Pointers
Suspend Automatic Rebuilds
swdisp.cpp and swdisp.h Files
System Options and Document Properties
Tessellation and Edges
Tracking IDs
Type Libraries
VBA and SolidWorks x64
Units
Unmanaged C+ and C++/CLI Code Differences
Examples and Projects
SolidWorks API Help
FeatureWorks API Help
SolidWorks Document Manager API Help
eDrawings API Help
SolidWorks Routing API Help
SolidWorks Simulation API Help
SolidWorks Utilities API Help
SolidWorks Workgroup PDM API Help
Hide Table of Contents Show Table of Contents

Accessing SolidWorks Objects

To call any of the SolidWorks API's methods or properties, you first need to obtain the object. For example, to use the IFace2::GetArea method you need to have a IFace2 object.

There are various ways to access objects within the SolidWorks API. To obtain the Face2 object, you could use one of the following accessors:

  • Obtain the IBody2 object using IPartDoc::GetBodies2 or IPartDoc::EnumBodies3, and then traverse the faces on the body using the IBody2::GetFirstFace and IFace2::GetNextFace methods.

    - or -

  • Get the IFace2 object from the current set of selected items using ISelectionMgr::GetSelectedObject6.

    - or -

  • Get the IFace2 object by its name using IPartDoc::GetEntityByName.

When you have the IFace2 object, you can access the properties and methods found in the Face2 class. For example, you could get the number of edges on the face using the IFace2::GetEdgeCount method, or you could get the normal vector for the face using the IFace2::Normal property.

NOTE: Some methods and properties, such as IFeatureManager::InsertMateReference, also require one or more selected items. The items can be selected in one of two ways:

  • The end-user can interactively select the items.

    - or -

  • You can programmatically select the items using IModelDocExtension::SelectByID2.

 



Related SolidWorks Forum Content

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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Accessing SolidWorks Objects
*Comment:  
x

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
x

Web Help Content Version: API Help (English only) 2012 SP05

The search functionality within the web help is in a beta test phase and you may experience periodic delays or interruptions in its performance. These are the normal and ordinary features of a beta test and shall not under any circumstances give rise to any liability on the part of DS SolidWorks or its licensors. The topics within the Web-based help are not beta topics; they document API Help (English only) 2012 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.