public static List<Point3d> GetUserDefinedPointsForDimension(double drawScale,DimensionStyle dimStyle, string prompt)
{
    List<Point3d> points = new List<Point3d>();

    // Get the first point from the user
    Point3d firstPoint = GetPointFromUser(prompt + " First Point: ");
    if (!firstPoint.IsValid)
    {
        RhinoApp.WriteLine("Invalid first point.");
        return points;
    }
    points.Add(firstPoint);

    // Get the second point from the user with dynamic line feedback
    using (var getPointAction = new GetPoint())
    {
        getPointAction.SetCommandPrompt(prompt + " Second Point: ");
        getPointAction.DynamicDraw += (sender, e) =>
        {
            e.Display.DrawLine(firstPoint, e.CurrentPoint, System.Drawing.Color.DarkCyan);
        };

        if (getPointAction.Get() == GetResult.Point)
        {
            Point3d secondPoint = getPointAction.Point();
            if (!secondPoint.IsValid)
            {
                RhinoApp.WriteLine("Invalid second point.");
                return points;
            }
            points.Add(secondPoint);
        }
        else
        {
            RhinoApp.WriteLine("Second point selection cancelled.");
            return points;
        }
    }

    // Get the third point from the user with dynamic dimension feedback
    using (var getPointAction = new GetPoint())
    {
        getPointAction.SetCommandPrompt(prompt + " Third Point: ");
        getPointAction.DynamicDraw += (sender, e) =>
        {
            Plane currentDocPlane = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
            Transform rotation = Transform.Rotation(Math.PI / 2, Point3d.Origin);
            currentDocPlane.Transform(rotation);
            LinearDimension dimension = LinearDimension.Create(
                AnnotationType.Aligned,
                dimStyle,
                currentDocPlane,
                currentDocPlane.XAxis,
                points[0],
                points[1],
                e.CurrentPoint,
                0);

            e.Display.DrawAnnotation(dimension, System.Drawing.Color.DarkCyan);
        };

        if (getPointAction.Get() == GetResult.Point)
        {
            Point3d thirdPoint = getPointAction.Point();
            if (!thirdPoint.IsValid)
            {
                RhinoApp.WriteLine("Invalid third point.");
                return points;
            }
            points.Add(thirdPoint);
        }
        else
        {
            RhinoApp.WriteLine("Third point selection cancelled.");
            return points;
        }
    }

    return points;
}

I have this method but I need to refactor it to creat a true lenear dimension we need something like this:
Plane currentDocPlane1 = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
Plane currentDocPlane2 = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
Transform rotation = Transform.Rotation(Math.PI / 2, Point3d.Origin);

Plane currentDocPlane =currentDocPlane1 ;

currentDocPlane2.Transform(rotation);
and some boolean checking based on the current coordinates of the 3rd point.
for default the use currentDocPlane1 .
if the position of  e.CurrentPoint.X gets out side of the range of points[0].X and points[1].X(you should first check these two X to determine the start and end of domain range) and e.CurrentPoint.Y is between the domain range of points[0].Y and points[1].Y(you should first check these two Y to determine the start and end of domain range)
the currentDocPlane = currentDocPlane2;
and it will be that until the e.CurrentPoint.Y gets out side of the domain range of points[0].Y and points[1].Y and  e.CurrentPoint.X is between the domain range of points[0].X and points[1].X