2 Replies Latest reply on Mar 27, 2017 4:55 PM by Gábor Veláncsics

    Why I receive 0,0,0 from GetSelectionPoint2 after the first selection?

    Gábor Veláncsics

      If I select a point on model than I receive 0,0,0 for xyz coordinates from GetSelectionPoint2 method. After that If I select a new point than I get the proper values.

      I use this macro from this conversation: https://forum.solidworks.com/message/234295#comment-234295

      Dim swApp As SldWorks.SldWorks
      Dim Part As ModelDoc2
      Dim Comp As SldWorks.Component2
      Dim SelMgr As SldWorks.SelectionMgr
      Dim bRet As Boolean

      Sub main()
      Dim Point As Variant
      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc
      Set SelMgr = Part.SelectionManager
      'Get xyz of selected face edge point etc.
      Point = SelMgr.GetSelectionPoint2(1, -1)
      'Print xyz
      Debug.Print "X= " & Point(0)
      Debug.Print "Y= " & Point(1)
      Debug.Print "Z= " & Point(2)
      'Print result of selecting component
      Debug.Print Part.Extension.SelectByID2("", "COMPONENT", Point(0), Point(1), Point(2), False, 0, Nothing, 0)
      'Get component and then print name.
      Set Comp = SelMgr.GetSelectedObject6(1, -1)
      Debug.Print "Selected " & Comp.Name
      End Sub