Below is the code for the following workflow:
- Initial state:
- Deleted some members of the vertical baseline dim set :

- Created new baseline dim set on the right, adjusted origin

- Ran rule, the result is:
If this is what you need, the code is below:
Imports System.Collections.Generic
Sub Main()
Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim tr As Transaction = ThisApplication.TransactionManager.StartTransaction(doc, "Remove duplicated dimensions")
Try
Dim dims As DimensionsSqueezer = New DimensionsSqueezer(sheet)
MsgBox("Original count: " + dims.OriginalCount.ToString() + ", Unique dims count: " + dims.Count.ToString())
dims.Squeeze()
tr.End()
Catch
tr.Abort()
End Try
End Sub
Class DimensionsComparer
Implements IEqualityComparer(Of LinearGeneralDimension)
Public Overloads Function Equals (ByVal d1 As LinearGeneralDimension, ByVal d2 As LinearGeneralDimension) _
As Boolean Implements IEqualityComparer(Of LinearGeneralDimension).Equals
If d1 Is Nothing And d2 Is Nothing Then Return True
If d1 Is Nothing Or d2 Is Nothing Then Return False
If d1.DimensionType <> d2.DimensionType Then Return False 'don't mix vert and hor dims
Return String.Equals( d1.Text.Text , d2.Text.Text, StringComparison.OrdinalIgnoreCase)
End Function
Public Overloads Function GetHashCode(ByVal d As LinearGeneralDimension) _
As Integer Implements IEqualityComparer(Of LinearGeneralDimension).GetHashCode
Return d.Text.Text.GetHashCode() Xor d.DimensionType
End Function
Public Shared Instance As IEqualityComparer(Of LinearGeneralDimension) = New DimensionsComparer
End Class
Class DimensionsSqueezer
Inherits HashSet(Of LinearGeneralDimension)
Public Sub New(sh As Sheet)
MyBase.New(DimensionsComparer.Instance)
BLDS = sh.DrawingDimensions.BaselineDimensionSets
For Each bds As BaselineDimensionSet In BLDS
For Each lgd As LinearGeneralDimension In bds.Members
Add(lgd)
OriginalCount+=1
Next
Next
End Sub
Public Sub Squeeze()
Dim toDelete As HashSet(Of LinearGeneralDimension) = New HashSet(Of LinearGeneralDimension)
For Each bds As BaselineDimensionSet In BLDS
For i As Integer = 1 To bds.Members.Count
Dim lgd As LinearGeneralDimension = bds.Members(i)
If Contains(lgd) Then
' Keeping dimension, updating hash
Remove( lgd)
Else
'Mark for delete
toDelete.Add(lgd)
End If
Next
Next
' MsgBox("Dimensions to be deleted : " + toDelete.Count.ToString())
For Each lgd As LinearGeneralDimension In toDelete
lgd.Delete()
Next
End Sub
Public Dim OriginalCount As Integer
Dim BLDS As BaselineDimensionSets
End Class
The important is the code in DimensionsComparer.Equals, which furnishes the criteria for the equality of two linear dimensions. In my example, the code compares the texts of the same dimension types. You may wish to change it. Also, the code is wrapped into transaction, to speed up a bit, and also to easily roll back the action.
Thank you,

Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.