Assembly components automation using SOLIDWORKS API

Edit ArticleEdit Article

Component in SOLIDWORKS assembly is an instance of the model documents (IModelDoc2) in assembly.

Components can be automated via IComponent2 interface available in SOLIDWORKS API.

The main operations on components include, but not limited to:

  • Transformation
  • Mating
  • In context editing
  • BOM composition

Pointer to the underlying document of the component can be retrieved via IComponent2::GetModelDoc2 SOLIDWORKS API method. This method returns null for suppressed or lightweight components. Refer the Get Model Doc For Lightweight Component for code example demonstrating how to retrieve the pointer to all types of components.

Explore this section for code examples and macros of automating assemblies and components.


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial