AnsweredAssumed Answered

How to use API to get point coordinate with reference to origin in the space rather than with reference to sketch origin?

Question asked by Chiao Yang Chang on Mar 7, 2018
Latest reply on Mar 7, 2018 by Artem Taturevych

The point I get from the code below is (-100,50,0) which is with reference to sketch origin (Fig1).

How to use API to get point coordinate with reference to origin in the space (Fig2) rather than with reference to sketch origin?

------------------------------------------------------------------------------------------------------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr

Dim SelPt As Variant

Public count As Long

 

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
   
    SelPt = swSelMgr.GetSelectionPoint2(1, -1)
    Debug.Print "X =" & SelPt(0) * 1000
    Debug.Print "Y =" & SelPt(1) * 1000
    Debug.Print "Z =" & SelPt(2) * 1000

 

End Sub

------------------------------------------------------------------------------------------------------------------------------

 

[Fig1] point coordinate = (-100,50,0)

 

[Fig2] point coordinate = (0,50,100)

 

[Fig3]

Outcomes