AnsweredAssumed Answered

Selecting a sketch segment after creating it

Question asked by Nikola Malesevic on Mar 31, 2017
Latest reply on Apr 1, 2017 by Nikola Malesevic

After creating a couple of sketch segments in a 2D sketch, I try to select them later on in order to make relations between them.


I have tested both SketchLine and SketchSpline, but the selection is not working.


Here is the minimum working example:


// Create new or select an existing empty sketch.
// We are now in sketch edit mode.
SketchSegment line1 = _document.SketchManager.CreateLine(0, 0, 0, 0, 0.1, 0);
SketchSegment line2 = _document.SketchManager.CreateLine(0.1, 0, 0, 0.1, 0.1, 0);
// Both lines created, line2 selected because it was just created.
// Clear selection and select.
line1.Select2(false, 0);


After executing this, line1 is not selected. If I omit clearing the selection, line2 stays selected, just as if I did not execute the last command.


Perhaps I don't have understanding about how the selection works. Am I doing something wrong here?


Using SolidWorks 2015 SP 5.0




The issue occurs only when doing an in-context editing of a part within an assembly, and it affects only sketch segments. Sketch points, for example, are not affected.


Even more minimum working example:



  • Have an assembly with one part in in-context editing mode.
  • Have an empty sketch in edit mode.
  • _document object retrieved from ISldWorks::ActiveDoc().
  • _sketch object retrieved from IFeature::GetSpecificFeature2() for a feature representing the sketch in the feature tree.


SketchSegment line = _document.SketchManager.CreateLine(0, 0, 0, 0, 0.1, 0);
// The line is automatically selected after creation.
// The line remains selected.