API: Using IComponent2::GetCorresponding in Assembly\Sub-Assembly\Part Hierarchy

Document created by Michael Kozikowski Employee on Feb 3, 2011Last modified by Michael Kozikowski Employee on Jan 2, 2013
Version 6Show Document
  • View in full screen mode

This C# macro example shows how to:

*  use IComponent2::GetCorresponding within an assembly hierarchy that has a sub-assembly component.

   (in this example, Assembly\Sub-Assembly\Part).

*  get a part (Part) feature in the context of the top-level assembly (Assembly).


The components are obtained within the context of their immediate parent document only. This is done by opening the parent document at each level when working your way down the FeatureManager design tree from Assembly to Sub-Assembly to Part. Once you have the part feature in the context of the Part document, you work your way back up the FeatureManager design tree by getting that feature in the context of its parent document (Sub-Assembly-obtained component) using IComponent2::GetCorresponding and then using that returned feature to get the top Assembly context by using (Assembly-obtained component) IComponent2::GetCorresponding.


The macro selects the part feature returned from the Assembly component to show that it is the same feature as was retrieved at the Part level.


You must be using either SolidWorks 2010 SP05 or 2011 SP02 and later for the macro to work. Open Assem1.sldasm and run the macro.


- Subscription Services required for full access.

- Looking for more API Examples?


Copyright © 2011 Dassault Systèmes SolidWorks Corp. All rights reserved.
Do not distribute or reproduce without the written consent of Dassault Systèmes SolidWorks Corp.