We are updating drawing views with similar parts, where we end up in getting lot of pink dimensions. Re-routing will not work for some dimensions, and we need to create new ones. To avoid writing ECN and also to ease the comparison of old and new drawings, we exactly overlap the dimension values. I was looking for an option built-in in Catia itself, but could not find one. Finally I was able to write the following macro: We need to use this macro along with Line-Up option to get the desired result.
Sub CATMain()
Dim DrwDoc As DrawingDocument
Set DrwDoc = CATIA.ActiveDocument
Dim dd As DrawingDimension
Dim xy(7) As Variant
Dim dd1 As Object
Dim m1, c1, m2, c2, x_intersection, y_intersection As Double
Dim oSel1 As Selection
Set oSel1 = CATIA.ActiveDocument.Selection
ReDim strArray1(1)
Dim sStatus1 As String
strArray1(0) = "DrawingDimension"
sStatus1 = oSel1.SelectElement3(strArray1, "Select Dimensions to Align", False, CATMultiSelTriggWhenUserValidatesSelection, False)
Set dd = oSel1.Item(1).Value
Set dd1 = oSel1.Item(2).Value
oSel1.Clear
dd1.GetBoundaryBox xy
m1 = (xy(7) - xy(1)) / (xy(6) - xy(0))
c1 = xy(1) - m1 * xy(0)
m2 = (xy(5) - xy(3)) / (xy(4) - xy(2))
c2 = xy(5) - m2 * xy(4)
If m1 - m2 <> 0 Then
int_x = (c2 - c1) / (m1 - m2)
int_y = m1 * int_x + c1
dd.MoveValue int_x, int_y, 1, 1
End If
End Sub