16 Replies Latest reply on Oct 24, 2018 4:06 PM by Nicolas Garceau

    Exporting xyz point coordinates from a 3D sketch.

    Cody Munk
      I have a 3D sketch with a hundered or so points. I would like to get the xyz data from these points. I have tried to save as a iges file and open that file in notebook, which lists all the values but I need to know which point is which. It seems like this should be a very easy thing to do, but I can't find a way. Basically we start our design with a spreadsheet full of points, we plot these points into SW and then design to them. Many points end up getting moved a little for fit of various mechanical items. Then after we design everything we need to update the xyz of the points that have changed. Thanks for any help!

      Cody
        • Exporting xyz point coordinates from a 3D sketch.
          Todd Engle
          Try saving as a .wrl
          • Re: Exporting xyz point coordinates from a 3D sketch.
            Tounine Mayer

            Cody,

             

            I know this is late, but I was hunting for a way to do this too, and thought I'd share what I found in case you can still use it.  In SolidWorks API help search for GetUserPoints2, there should be an example for Get Sketch Points and Persistent IDs (in VBA).  This will show you how to use a macro to get the points.  You will need to modify this to write the values to an array, rather than just printing them, and write the array to excel.  You can use the following code mod:

             

            Dim Coordinates()  -- This creates an array of dynamic dimension

            Dim ExcelSheet As Object

            Set ExcelSheet = CreateObject("Excel.Sheet")  -- This will start Excel and create a new file with an active worksheet

             

            In the second For i statement add

            ReDim Coordinates (3,(UBound(vSketchPt)))  -- This redimensions the array to the 4 x the number of sketch points

            You can then populate the array by something like

            Coordinates(0,i)=vSketchPtID(0)

            Coordinates(1,i)=swSketchPt.X*1000# --This is for mm, do the same for the other directions.

             

            ExcelSheet.Application.Cells(i+1,1)=Coordinates(0,i)

            ExcelSheet.Application.Cells(i+1,2)=Coordiantes (1,i)  -- This adds the values from the array to the spreadsheet, do this for the other dimensions too.

             

            You can then either use ExcelSheet.Application.Visible to show you spreadsheet

            or ExcelSheet.Application.SaveAs "C:\Test.xls" to save the file

             

            Hope this helps, I don't have my macro completely pieced together how I want it work yet, if you need more info let me know.

             

            Toni

            • Re: Exporting xyz point coordinates from a 3D sketch.
              Nicolas Garceau

              Hi there, I need some help plz. Im doing a test for a project  i need the coordinates and the id of the point to be exported in to excel.

              I dont know mutsh about that kind of programing . Ive tried two macro but one gave me juste one point but with 3 times the xyz coordinate and the other macro gave me the information like ive selected 8 point. The points is for a reference in an asembly of parts in a web generator. this is the model i tested with .

               

              pieces.jpg