2 Replies Latest reply on Apr 23, 2015 1:33 PM by Keith Rice

    Get Origin Position

    Di Anne

      Hi SW Community,

       

      I have this task to get the position of all origins of each part inside the sub assembly  child.
      QA origin.jpg

       

      Does anyone knows how to do this?

      It will be a  big help.

       

      Thanks in advance.

       

      Regards,

      Dianne

        • Re: Get Origin Position
          Simon Turner

          This information is contained within IComponent2::Transform2 for each component.

          • Re: Get Origin Position
            Keith Rice

            Select a component, run this macro, and observe the immediate window:

             

            Sub main()
                Dim swApp As SldWorks.SldWorks
                Dim swModel As SldWorks.ModelDoc2
                Dim swSelMgr As SldWorks.SelectionMgr
                Dim swComp As SldWorks.Component2
                Dim swTransform As SldWorks.MathTransform
                Dim vData As Variant
                
                Set swApp = Application.SldWorks
                Set swModel = swApp.ActiveDoc
                Set swSelMgr = swModel.SelectionManager
                Set swComp = swSelMgr.GetSelectedObject6(1, -1)
                Set swTransform = swComp.Transform2
                vData = swTransform.ArrayData
                
                Debug.Print "X: " & Round(vData(9), 6)
                Debug.Print "Y: " & Round(vData(10), 6)
                Debug.Print "Z: " & Round(vData(11), 6)
            End Sub
            

             

            Keith

            SolidWorks API Training