why the api InsertCoordinateSystem wrong

Hi All

I write a marco to insert coordinatesystem by sketch,but now i run the marco, Some will be repeated select a point to insert coordinate system or omission.

If i step by step to  run and there is no problem.can you help me?

the code:

For k = 0 To UBound(sketchPointArray)

                  

        Set swSketchPoint = sketchPointArray(k)

  

      

           Set swfeaturemgr = swmodel.FeatureManager

        boolstatus = swmodel.Extension.SelectByID2("", "EXTSKETCHPOINT", swSketchPoint.X, swSketchPoint.Y, swSketchPoint.Z, False, 1, Nothing, 0)

        Debug.Print swSketchPoint.X & swSketchPoint.Y & swSketchPoint.Z

        Set swfeather = swfeaturemgr.InsertCoordinateSystem(False, False, False)

     

     

SolidworksApi macros