This sample IS NOT FOR PRODUCTION USE!
I omit any error checking for brevity and this rule is written only for this very simple drawing. See attached file for functional example. In the drawing document is local rule with following text.
'Get active drawing document, sheet and view
Dim drwDoc As DrawingDocument = ThisDoc.Document
Dim drwSheet As Sheet = drwDoc.Sheets(1)
Dim drwView As DrawingView = drwSheet.DrawingViews(1)
'Get referenced assembly and its component definition
Dim asmDoc As AssemblyDocument = drwDoc.ReferencedDocuments(1)
Dim asmDef As AssemblyComponentDefinition = asmDoc.ComponentDefinition
'Get MateConstraint
Dim mateConstraint As MateConstraint = asmDef.Constraints("MateForDimension")
'Get face proxies from MateConstraint
Dim faceProxy1 As FaceProxy = mateConstraint.EntityOne
Dim faceProxy2 As FaceProxy = mateConstraint.EntityTwo
'Get DrawingCurves which belongs to face in appropriate DrawingView
Dim curves1 As DrawingCurvesEnumerator = drwView.DrawingCurves(faceProxy1)
Dim curves2 As DrawingCurvesEnumerator = drwView.DrawingCurves(faceProxy2)
'Select the right DrawingCurve
Dim curve1 As DrawingCurve = curves1.Item(1)
Dim curve2 As DrawingCurve = curves2.Item(1)
'Create GeometryIntent for this curve
Dim geometryIntent1 = drwSheet.CreateGeometryIntent(curve1)
Dim geometryIntent2 = drwSheet.CreateGeometryIntent(curve2)
'Select dimension text position
Dim textOrigin = drwView.Center
'Create DrawingDimension
drwSheet.DrawingDimensions.GeneralDimensions.AddLinear(textOrigin, geometryIntent1, geometryIntent2)