Auto-Align Dims

I am attempting to auto align dimensions on a drawing from the api as they tend to move when the model resizes in the view (or features are added/removed).  I am getting inconsistent results at best... some dimensions align, some go way off the page. Some start out way off the page and never come in (even though there aren't any dimensions keeping it from coming in).

It is absolutely critical I get this working as these drawings are being generated automatically and I can't afford to have someone touch each one to fix it.

Any help wold be appreciated.  Below is my code:

'Select all the dimensions
oAnn = swView.GetAnnotations()
For Each swAnn In oAnn
     If swAnn.Visible = SwConst.swAnnotationVisibilityState_e.swAnnotationVisible And swAnn.GetType = SwConst.swAnnotationType_e.swDisplayDimension Then
                    
        If swModelDoc.Extension.SelectByID2(swAnn.GetName & "@" & swView.GetName2, "DIMENSION", 0, 0, 0, True, 0, Nothing, SwConst.swSelectOption_e.swSelectOptionDefault) Then
            Debug.Print("Selected: " & swAnn.GetName & "@" & swView.GetName2)
        Else
            Debug.Print("Failed to select: " & swAnn.GetName & "@" & swView.GetName2)
        End If

      End If
  Next

'Auto align the dimensions
swModelDoc.Extension.AlignDimensions(SwConst.swAlignDimensionType_e.swAlignDimensionType_SpaceEvenly, 1)
               
swModelDoc.ClearSelection2(True)

It is critical I get this working as soon as possible.

Thanks,

Eric Swartz

SolidworksApi macros