An ISketchSegment has an ID, but the ID is only unique within a specific sketch. So, multiple sketches can have different sketch segments with the same ID. An ISketchBlockInstance has an ISketchBlockDefinition with its own underlying sketch.
You can use a combination of the sketch segment ID and the entity's coordinates to find the sketch block instance to which the sketch segment belongs. Check each top-level sketch ISketchBlockInstance's ISketchBlockDefinition to get the sketch block definition's underlying sketch and compare sketch segment IDs and coordinates until you find the sketch segment.
The attached VBA macro and part document demonstrate how to do this. The combination of sketch segment ID and sketch segment curve coordinates (the example uses a spline) allows the macro to accept or reject the similarly ID'd splines appearing in different sketch blocks in order to find the correct sketch segment. Testing directions appear at the top of the macro.
|- 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.