2 Replies Latest reply on Jun 5, 2014 7:57 AM by Craig Clanachan

    SetAddtoDB and grid snapping for sketch point importing from excel

    Craig Clanachan

      I am importing sketch points from excel using the macro  however points that are close to each other are snapping to horizontal or vertically alignment depending on the level of zoom when the marco is run.  I think I need to use the I.Sketch.Manager::SetAddtoDB function but I am not sure on the syntax to achieve this.


      Thanks in advance for your help


      Option Explicit
      Sub main()
      Dim swApp As SldWorks.SldWorks
      Dim Part As SldWorks.ModelDoc2
      Dim Excel As Object
      Dim i As Integer
      Dim xpt As Double
      Dim ypt As Double
      Dim zpt As Double

      Set swApp = Application.SldWorks
      Set Part = swApp.ActiveDoc
      Set Excel = GetObject(, "Excel.Application")

      Part.SketchManager.InsertSketch True
      i = 1
      Do While Excel.Cells(i, 1) <> ""
          xpt = Excel.Cells(i, 1) / 1000
          ypt = Excel.Cells(i, 2) / 1000
          zpt = Excel.Cells(i, 3) / 1000
          Part.CreatePoint2 xpt, ypt, zpt
          i = i + 1