Hide Table of Contents

Understanding the SolidWorks API Class Hierarchy

SolidWorks does not document its APIs with a complete a class hierarchy diagram, much like the famous MFC and .NET/WinFX class hierarchy diagrams. The reason for this is that MFC and .NET rely heavily on:

  • Classes

  • Implementation inheritance

  • Casting between classes using static casts (C++)

These types of class libraries and APIs can often benefit from a hierarchy diagram.

 However, SolidWorks is a COM-based API that uses:

  • Interfaces

  • Interface inheritance

  • Factory methods to return interfaces on existing and new objects

  • Casting between interfaces through:

    • QueryInterface (C++), which returns a pointer to a specified interface on an object to which a client currently holds an interface pointer.
    • direct assignment (VB/VB.NET).
    • the is/as reserved words (C#).

While a graphical hierarchy diagram often does not convey as much information in this style of API, there are a few places where it can be useful.

Interface Inheritance in the SolidWorks API

Objects that implement:

 NOTE: The phrase can QueryInterface to is synonymous with implements or can be assigned to in Visual Basic.

While it is technically incorrect to say, for example, that IPartDoc derives from IModelDoc2, the way that developers use these interfaces is similar to the way they would use a derived class with implementation inheritance.

Using methods as an alternative to QueryInterface/Interface inheritance

There are several other areas of the API that use other methods to perform operations similar to a QueryInterface().

Accessors

To find out how to get a specific SolidWorks interface or object from other SolidWorks interfaces or objects, use the Accessors link located at the bottom of an interface's topic.

Reference material

For more information on classes, objects, casting, interfaces, QueryInterface, COM, and inheritance, see:

  • Inside COM by Dale Rogerson. (Microsoft Press)

  • Programming .NET Components by Juval Lowy (O'Reilly)



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:   Understanding the SolidWorks API Class Hierarchy
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



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

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.