ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
LBLouis Bouchard14/11/2013

Hi,

I am trying to create then delete a line in a sketch.  For testing purposes, I create two lines, and delete the first one.  Strange thing is, the following code results in the second line being deleted, even though the first one was explicitely selected.

                SketchManager skm = SWIntegration.Instance.getModel().SketchManager;

                skm.AddToDB = true;

 

                SketchSegment ss = skm.CreateLine(0, 0, 0, 1, 1, 0);

                ss.ConstructionGeometry = true;

               

                SketchSegment ss2 = skm.CreateLine(0, 0, 0, 1, 2, 0);

                ss2.ConstructionGeometry = true;               

                SelectData sd = SWIntegration.Instance.getSelectData();

                ss.Select4(false, sd);

                SWIntegration.Instance.getModel().EditDelete();

                skm.AddToDB = false;

I also tried clearing the selection before selecting the line to be deleted, like so:

                [...]

                SWIntegration.Instance.getModel().ClearSelection2(true);

                SelectData sd = SWIntegration.Instance.getSelectData();

                ss.Select4(true, sd);

                SWIntegration.Instance.getModel().EditDelete();

                [...]

... but then I see a message a the top right corner of the screen saying that "entities which do not belong to the active sketch cannot be deleted".  How can they not be in the active sketch?  I don't understand.

Thanks in advance,

Louis