Error when projecting points onto a surface in VBA

I am trying to project a point onto a curved surface in VBA and, while it shows in the tree, it is in error and states "unable to recompute topology tracking information".  Code is shown below:


Private Sub CommandButton1_Click()

 Dim objApp As SolidEdgeFramework.Application
 Dim objPartDoc As SolidEdgePart.PartDocument
 Dim objBody As SolidedgeGeometry.Body
 Dim objFaces As Object
 Dim XOffset As Double
 Dim YOffset As Double
 Dim ZOffset As Double
 Dim objClosestFace As Object
 Dim objConstructions As SolidEdgePart.Constructions
 Dim objProCurves As SolidEdgePart.ProjectCurves
 Dim objProPoint As SolidEdgePart.ProjectCurve
 Dim objSketch3D As SolidEdgePart.Sketch3D
 Dim objPoints3D As SolidEdgePart.Points3D
 Dim objPoint3D As SolidEdgePart.Point3D
 Dim dblPointCoord(3) As Double
    Const Conversion = 39.370079
    On Error Resume Next
    Set objApp = GetObject(, "SolidEdge.Application")
    If Err Then
        Set objApp = CreateObject("SolidEdge.Application")
        Set objPartDoc = objApp.Documents.Add("SolidEdge.PartDocument")
        objApp.Visible = True
        Set objPartDoc = objApp.ActiveDocument
    End If
 On Error GoTo 0

        Set objBody = objPartDoc.Models(1).Body
        Set objFaces = objBody.Faces(FaceType:=igQueryAll)
        Set objClosestFace = objFaces.Item(1)
        XOffset = 0.5 / Conversion
        YOffset = 0.6 / Conversion
        ZOffset = 0.6 / Conversion
        Set objConstructions = objPartDoc.Constructions
        Set objProCurves = objConstructions.ProjectCurves
' try projecting point by using coordinates:
        Set objProPoint = objProCurves.AddPoint(AnyEdgeToDefineOrigin:=Nothing, KeyPointFlags:=igKeyPointPointOnly, Secondary:=objClosestFace, RefPlane:=Nothing, ProjectDir:=igNone, ProjectOption:=igNormal, dXDim:=XOffset, dYDim:=YOffset, dZDim:=ZOffset, nPrimary:=0)
' try projecting point by using a point reference:

        dblPointCoord(0) = XOffset
        dblPointCoord(1) = YOffset
        dblPointCoord(2) = ZOffset
        Set objSketch3D = objPartDoc.Sketches3D.Add()
        Set objPoints3D = objSketch3D.Points3D
        Set objPoint3D = objPoints3D.Add(3, dblPointCoord)

        Set objProPoint = objProCurves.AddPoint(AnyEdgeToDefineOrigin:=objPoint3D, KeyPointFlags:=igKeyPointPointOnly, Secondary:=objClosestFace, RefPlane:=Nothing, ProjectDir:=igNone, ProjectOption:=igNormal, dXDim:=Nothing, dYDim:=Nothing, dZDim:=Nothing, nPrimary:=1)

End Sub

In the second projection, I create a 3D sketch point using the coordinates and attempt to use that for the projection.  I get a "type mismatch" error on that command.  Am I referencing the point incorrectly?  I am able to project 3D points normally, but can't seem to using the API.


The solid model I test this on is a simple cylinder of 1" radius with the cylinder axis on the X axis.


I am using VBA because this part of a larger project that will process values from an excel spreadsheet.


I'd appreciate any assistance on either of these two issues!


Scott Ralston