I am calling CreateCornerRectangle like this:

Dim x1 As Double = -4 * 0.0254

Dim y1 As Double = 90 * 0.0254

Dim z1 As Double = 0

Dim x2 As Double = 4 * 0.0254

Dim y2 As Double = 102 * 0.0254

Dim z2 As Double = 0

vSkLines = CType(swDoc.SketchManager.CreateCornerRectangle(x1, y1, z1, x2, y2, z2), Array)

With the above values everything works as expected. However, with the values below the CreateCornerRectangle function returns an empty array (notice that only x1 and x2 have changed)

Dim x1 As Double = -1 * 0.0254

Dim y1 As Double = 90 * 0.0254

Dim z1 As Double = 0

Dim x2 As Double = 1 * 0.0254

Dim y2 As Double = 102 * 0.0254

Dim z2 As Double = 0

vSkLines = CType(swDoc.SketchManager.CreateCornerRectangle(x1, y1, z1, x2, y2, z2), Array)

Can somebody give me some ideas as to what I may be doing wrong?

In case it helps, here is the entire piece of code:

Public Sub main()

Dim x1 As Double = -1 * 0.0254

Dim y1 As Double = 90 * 0.0254

Dim z1 As Double = 0

Dim x2 As Double = 1 * 0.0254

Dim y2 As Double = 102 * 0.0254

Dim z2 As Double = 0

Dim swDoc As ModelDoc2 = Nothing

Dim swPart As PartDoc = Nothing

Dim swDrawing As DrawingDoc = Nothing

Dim swAssembly As AssemblyDoc = Nothing

Dim boolstatus As Boolean = False

Dim longstatus As Integer = 0

Dim longwarnings As Integer = 0

swDoc = CType(swApp.ActiveDoc, ModelDoc2)

boolstatus = swDoc.Extension.SelectByID2("PrincipalPostBack", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swDoc.Extension.SelectByID2("PrincipalPostBack", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

swDoc.FeatureManager.HideBodies()

swDoc.SketchManager.InsertSketch(True)

boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.25400000000007594, 2.5120206377875931, -0.012534936826966714, False, 0, Nothing, 0)

swDoc.ClearSelection2(True)

boolstatus = swDoc.Extension.SetUserPreferenceToggle(CType(swUserPreferenceToggle_e.swSketchAddConstToRectEntity, Integer), CType(swUserPreferenceOption_e.swDetailingNoOptionSpecified, Integer), False)

boolstatus = swDoc.Extension.SetUserPreferenceToggle(CType(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType, Integer), CType(swUserPreferenceOption_e.swDetailingNoOptionSpecified, Integer), True)

Dim vSkLines As Array = Nothing

vSkLines = CType(swDoc.SketchManager.CreateCornerRectangle(x1, y1, z1, x2, y2, z2), Array)

swDoc.ClearSelection2(True)

swDoc.SketchManager.InsertSketch(True)

End Sub

Try to set this property to True: 2013 SOLIDWORKS API Help - AddToDB Property (ISketchManager) before creating the rectangle.

Thanks,

Artem