Getting the location of display dimension lines in a drawing

I'm working on some drawing automation, and I need to reference the location of display dimension witness lines and dimension arrows. I've been using ModelDocExtension::AlignDimensions to do the bulk of the sorting of dimensions on drawings, but this method isn't consistent enough for automation. For example, I'm still having trouble with dimension text being placed on top of witness lines, or centered between witness lines that are too close together for the text to fit between, not to mention the hijinks that arclength or radius dimensions get into.

DisplayDimension text location is easy; but I think I might have hit the wall looking for the reference lines. It looks like Dimension::referencepoints might provide some clues, but I think I'm doing something wrong when I try to get each of the reference points. For example, there will be n points returned, and when I attempt to return referencepoints(n), the arraydata all return 0.

Or, am I overlooking a better way to return these values? For the moment, I'm stuck doing this in VBA, but if I need to do this in .net or C++, I'll find a way.

Option Explicit</p><p></p><p>Dim swApp As SldWorks.SldWorks</p><p>Dim swModel As SldWorks.ModelDoc2</p><p>Dim swDrawing As SldWorks.DrawingDoc</p><p>Dim swView As SldWorks.view</p><p>Dim swDispDim As SldWorks.DisplayDimension</p><p>Dim swDim As SldWorks.dimension</p><p>Dim swPoint As SldWorks.MathPoint</p><p>Dim swMath As SldWorks.MathUtility</p><p>Dim refpoints As Variant</p><p>Dim i As Integer</p><p></p><p>Sub main()</p><p></p><p>Set swApp = Application.SldWorks</p><p>Set swModel = swApp.ActiveDoc</p><p>Set swDrawing = swModel</p><p>Set swView = swDrawing.GetFirstView</p><p>Set swMath = swApp.GetMathUtility</p><p></p><p>Debug.Print String(255, vbNewLine)</p><p></p><p>Do While Not swView Is Nothing</p><p>    If swView.GetVisible Then</p><p>    Set swDispDim = swView.GetFirstDisplayDimension5</p><p>        Do While Not swDispDim Is Nothing</p><p>            Set swDim = swDispDim.GetDimension2(0)</p><p>            Debug.Print "Dimension name: " & swDim.GetNameForSelection</p><p>            Debug.Print "Reference points count: " & swDim.GetReferencePointsCount</p><p></p><p>            For i = 0 To swDim.GetReferencePointsCount - 1</p><p>                Set swPoint = swMath.CreatePoint(swDim.referencepoints(i)) ' this doesn't produce any errors, but isn't the right way</p><p>                Debug.Print swPoint.ArrayData(0) & "   " & swPoint.ArrayData(1) & "   " & swPoint.ArrayData(2) ' these all return as 0</p><p>            Next i</p><p></p><p>            Set swPoint = swMath.CreatePoint(swDim.referencepoints)</p><p>            Debug.Print swPoint.ArrayData(0) & "   " & swPoint.ArrayData(1) & "   " & swPoint.ArrayData(2) ' this returns nonzero values</p><p></p><p>            Set swDispDim = swDispDim.GetNext5</p><p>            Debug.Print vbNewLine</p><p>        Loop</p><p>    End If</p><p>    Set swView = swView.GetNextView</p><p>Loop</p><p></p><p>End Sub

SolidworksApi macros