There is a solidworks assembly containing a point "P" and a coordinate system frame "F". The goal is to find x,y,z coordinates of the point "P" wrt the frame "F". The VB code looks like
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim bstatus As Boolean
Dim swMeasure As SldWorks.Measure
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.ClearSelection2 True
bstatus = swModel.Extension.SelectByID2("P", "DATUMPOINT", 0, 0, 0, False, 0, Nothing, 0)
Debug.Assert bstatus
Set swMeasure = swModel.Extension.CreateMeasure
bstatus = swMeasure.Calculate(Nothing)
Debug.Assert bstatus
Debug.Print ("X: " & swMeasure.X)
Debug.Print ("Y: " & swMeasure.Y)
Debug.Print ("Z: " & swMeasure.Z)
End Sub
The script works, but it gives coordinates in recently used coordinate system frame. It can be the frame "F" or the default frame, so the result is unpredictable. I couldn't find the properties of the Measure class to force it to use the necessary frame. Is there a way to explicitly specify the frame? Is there a workaround?