ISketchSegment::SplitEntity() method fails when performing an in-context part editing.
I create a new 2D sketch, draw one horizontal line from (-100, 0) to (100, 0), in millimeters, and then execute the code below:
<p>IModelDoc2 document = _iSwApp.ActiveDoc; // _iSwApp is ISldWorks object.</p><p>ISelectionMgr sm = document.SelectionManager;</p><p>ISketchSegment segment = sm.GetSelectedObject6(1, -1);</p><p>//segment.ConstructionGeometry = true; // Converting to construction line works just fine, but I'm not interested in it.</p><p>segment.SplitEntity(0.010, 0, 0, 0, 0, 0);</p><p></p>
Three scenarios:
- Part editing, sketch belongs to the part: works fine, the line is split at 10 mm right of the origin.
- Assembly editing, sketch belongs to the assembly: works fine, the line is split at 10 mm right of the origin.
- Part in-context editing, sketch belongs to the part within an assembly: throws an exception below.
<p>System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</p><p> at modelDocSketch_c.moSketchInProgr(modelDocSketch_c* )</p><p> at SketchCoupling.SketchToolsCoupler_c.getUoSketch()<br> at SketchCoupling.SketchToolsCoupler_c.ConvertSketchToScreen(CorePoint_s sketch)<br> at APICoupler.apiSplitEntityCoupler_c.populateDataPacket()<br> at APICoupler.apiCoupler_c<apiSplitEntityData_c\\,SketchOperation::SplitLineOperation_c\\,SolidCore::ProfileRequest_c\\,SolidCore::ProfileRequest_c::SplitEntityPacket_c>.run()<br> at SolidWorks.Interop.sldworks.ISketchSegment.SplitEntity(Double X, Double Y, Double Z, Double ClosedX, Double ClosedY, Double ClosedZ)<br> at WeldingPlanner.SwAddin.ShowPageAddPass() in C:\\D\\Local\\CoRoWeld\\Welding Planner\\src\\Welding Planner\\SwAddin.cs:line 170</p>
I am suspecting yet another bug with in-context editing.
Can anybody confirm or deny the behavior?
Using SolidWorks 2015 SP5.0
SolidworksApi macros