There's a lot of ways you could do this. Ultimate you just need to get the sketch points (ISketchPoint) used in the rectangle and then use ISketchPoint::X,Y,Z to get the locations relative to one another.
To get the sketch points, here are two options:
1. Use ISketch::GetSketchPoints2 to get all of the sketch points in the current sketch. (You can use IModelDoc2::GetActiveSketch2 to get the ISketch pointer)
2. ISketchManager::CreateCenterRectangle returns ISketchSegment pointers (including reference geometry). You can cast these to ISketchLine and then use ISketchLine::GetEndPoint2 and ISketchLine::GetStartPoint2 to get the start and end points, which are ISketchPoint objects.
To cast you simply do this:
Dim swSketchSeg as SldWorks.SketchSegment
Dim swSketchLine as SldWorks.SketchLine
Set swSketchLine = swSketchSeg
Test if a segment is reference geometry like this:
If swSketchSeg.ConstructionGeometry = 0 Then
'Do your work
Thank you for clearing that up! The second method you outlined is the direction I'm trying to go. It never would have occurred to me to re-cast the SketchSegment to a SketchLine; I didn't realize that was an option.
For some reason, the GetStartPoint2 method wouldn't work for me; it returned the "Object doesn't support this property or method" runtime error. The obsolete GetStartPoint method, however, worked just fine.
Here's the test code that worked for me:
Dim swApp As Object
Dim Part As Object
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim vSkLines() As SldWorks.SketchSegment
Dim skSeg As SldWorks.SketchLine
vSkLines = Part.SketchManager.CreateCenterRectangle(0, 0, 0, 9.78999538527745E-02, -5.23883444770945E-02, 0)
Set skSeg = vSkLines(0)
end1 = skSeg.GetEndPoint
MsgBox end1(0) & vbNewLine & end1(1) & vbNewLine & end1(2)