7 Replies Latest reply on Jul 24, 2018 10:29 AM by Michael Gnadlinger

    Accuracy Problems when reading a txt file

    Michael Gnadlinger

      Hey out there,


      I have a txt file with the x, y and z coordinates of 500+ holes and this is my macro-code for sketching the circles:


      Sub main()


          Dim myFile As Integer


          Dim swApp As SldWorks.SldWorks

          Dim skSegment As SldWorks.SketchSegment

          Dim Part As SldWorks.ModelDoc2

          Dim swModelView As SldWorks.ModelView


          Dim Xc As Double

          Dim Yc As Double

          Dim Zc As Double


          myFile = FreeFile


          Open "C:\my.txt" For Input As #myFile


          Set swApp = Application.SldWorks

          Set Part = swApp.ActiveDoc

          Set swModelView = Part.ActiveView

          swModelView.FrameState = swWindowState_e.swWindowMaximized



          Do Until EOF(myFile)


              Input #myFile, Xc, Yc, Zc

              Set skSegment = Part.SketchManager.CreateCircleByRadius(Xc / 1000, Yc / 1000, Zc / 1000, 0.03)




          Part.SketchManager.InsertSketch True

          Close myFile


      End Sub



      At first it seemed to work perfectly fine, but the accuracy of the centers of the circles vary a lot by how far i zoomed in/out when starting the macro, the further I zoomed in the more accurate the sketch became (see the attachment (blue is when zoomed out, grey when zoomed in)). From a few mm when zoomed in really far, to even missing some circles when zoomed out far enough.


      Where does this issue come from and how can I solve this issue?


      Many Thanks in advance,


      Miachel Gnadlinger