I am having a similar issue, but I have already resolved the face proxy to a face object.
I am trying to create a sketch centered on a face, so I have identified the center point and can successfully place a work point at that location, but cannot seem to use it as the origin of the sketch.
Dim oPartDoc As Inventor.PartDocument
If ThisApplication.ActiveDocumentType = kpartDocumentObject Then
oPartDoc = ThisApplication.ActiveDocument
Else If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject And ThisApplication.ActiveEditDocument.DocumentType = kpartDocumentObject Then
oPartDoc = ThisApplication.ActiveEditDocument
Else
i = MessageBox.Show("No part file selected for edit", "No Part for Edit", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Exit Sub
End If
Dim oCompDef As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTransGeom As Inventor.TransientGeometry = ThisApplication.TransientGeometry
Dim oPickFace As Inventor.FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Text")
Dim oSketchAxis As Inventor.Edge
Dim oSketchFace As Inventor.Face = oPickFace.NativeObject
Dim edge1 As Inventor.Edge = oSketchFace.Edges.Item(1)
Dim edge2 As Inventor.Edge = oSketchFace.Edges.Item(2)
Dim curve1Eval As CurveEvaluator = edge1.Evaluator
Dim curve2Eval As CurveEvaluator = edge2.Evaluator
Dim maxP As Double
Dim minP As Double
Dim curveLength1 As Double
Dim curveLength2 As Double
Call curve1Eval.GetParamExtents(minP,maxP)
Call curve1Eval.GetLengthAtParam(minP, maxP, curveLength1)
Call curve2Eval.GetParamExtents(minP, maxP)
Call curve2Eval.GetLengthAtParam(minP, maxP, curveLength2)
If curveLength1 > curveLength2 Then
oSketchAxis = edge1
Else
oSketchAxis = edge2
End If
Dim oEdgeLoop As Inventor.EdgeLoop = oSketchFace.EdgeLoops.Item(1)
Dim oMinPt As Inventor.Point = oEdgeLoop.RangeBox.MinPoint
Dim oMaxPt As Inventor.Point = oEdgeLoop.RangeBox.MaxPoint
Dim oCtPoint As Inventor.Point = oTransGeom.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)
'Fails here at sketch creation
Dim oSketch As Inventor.PlanarSketch = oCompDef.Sketches.AddWithOrientation(oSketchFace, oSketchAxis, True, True, oCtPoint)