1 Reply Latest reply on Sep 15, 2017 9:38 AM by Matthew Cempa

    How can I export datum points referenced from a custom coordinate system into excel?

    Zach L.

      How can I export datum points referenced from a custom coordinate system into excel? I have found macros for sketch points but nothing for points referenced from a custom coordinate system, or even anything using datum points. Please help. I am dumbfounded.

        • Re: How can I export datum points referenced from a custom coordinate system into excel?
          Matthew Cempa

          you need transform the point from global to local coordinates.  There are many transforms happening in SolidWorks.  If you are working in a part it's pretty straight forward as below.  If you are in an assembly looking at a point in a component there is a transform for the component that comes into play.  On top of that in a drawing there is a view transform that needs to be accounted for.  I'll leave the excel work out of this post.  I have a complete macro to do this but unfortunately I can not share the entire macro here but I can share the basic technique required.  Hope this helps.  I pulled out some my code but this is not tested as is but works in my final code.

           

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swFeat As SldWorks.Feature

          Dim swCsys As SldWorks.CoordinateSystemFeatureData

          Dim swTransform As SldWorks.MathTransform

          Dim swPt As SldWorks.MathPoint

          Dim swLocalPt As SldWorks.MathPoint

           

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swMath = swApp.GetMathUtility

          Set swFeat = swSelMgr.GetSelectedObject6(1, 0) 'assumes the Csys is the first item selected.

          Set swCsys = swFeat.GetDefinition

          Set swTransform = swCsys.Transform

           

          ' Code to get the point to work with goes here

          ....

           

          Set swLocalPt = swAssyPt.MultiplyTransform(swTransform.Inverse)