I solved this problem after alot of frustration. The key was to assign the x, y, & z properties of the ISketchPoint object to a double array instead of a variant for the transform.
This issue is known by SolidWorks API Dev team, FYI:
SPR 860142 : CreatePoint Method (IMathUtility) fails when pass Parameter Array as an argument.
If you email email@example.com and ask them to add you to the notification list, you'll be notified when the bug is resolved.
I was trying to locate the XYZ coordinates by doing an inverse IMathTransform on the coordinates of the ISketchPoint object. The issue was when I would obtain the object through the ISelectionMgr by using the code to select it, I was getting coordinates of (0, 0, 0). The only way I was getting the correct coordinates with ISelectionMgr was to mouse select the point. Then, when I was accessing the point object by ISketch::GetSketchPoints and reading the X, Y, & Z properties into a variant array, the transform was coming out incorrect.
Once I figured out to read the properties into a array of type double, the transform was correct.
The reason I was using a variant array in the first place is the sample code in the API help example "Transform Coordinates from Sketch to Model Space Example (VBA)". I eventually found an example - forgive me but right now I am unable to find it - in the API help that used the array of double type and obviously by now you know that solved the problem.
By the way, when I searched for the SPR in the knowledge base, I couldn't find it.
The example I found my eventual solution in was "Get x,y,z Locations of Points in Sketch Example (VBA)".
I know it has been some time since you posted this. Is it possible to publish the code that involves the solution to this? I have a macro that gets the tess points of a sketch segment inside of a block instance which is inserted into a sketch. The returned tess points are in the blocks original sketch space coordinates. I want to transform the coordinates to model space and the only way that I've found to accomplish this was actually creating a temporary point, measuring it, and then deleting it. The measurements returned to me are in model space. Looking to shortcut this.
Thanks in advance,
I created a function within a much larger macro that utilized it.
'transform a sketch point's coordinates into model space
Private Function GetModelCoordinates(swSketch As SldWorks.Sketch, pointNum As Integer) As Variant
Dim swMathUtil As SldWorks.MathUtility
Dim swMathPt As SldWorks.MathPoint
Dim swMathTrans As SldWorks.MathTransform
Dim ptCoord(2) As Double
Dim ptObj As Object
Set ptObj = swSketch.GetSketchPoints2(pointNum - 1)
ptCoord(0) = ptObj.X: ptCoord(1) = ptObj.Y: ptCoord(2) = ptObj.Z
Set swMathUtil = swApp.GetMathUtility
Set swMathPt = swMathUtil.CreatePoint(ptCoord)
Set swMathTrans = swSketch.ModelToSketchTransform.Inverse
Set swMathPt = swMathPt.MultiplyTransform(swMathTrans)
GetModelCoordinates = swMathPt.ArrayData
Thanks for the quick response. I'll see what I can do with it.