How to set LinearDimension (text) value horizontal to view

Hi! I am not an experienced programmer. I am trying to add dimensions to a list of curves, and having difficulty with the vertical (y axis) dimensions in the xy plane. Could someone tell me how to rotate the dimension values 90 degrees, or make them horizontal to the viewport? The code below is working, but I am unable to change how the text is displayed in the heightDim dimension text.

public static List AddDimensionsToLayout(RhinoDoc doc, List curves, double spacing = 1.0, double dimensionFontSize = 0.2)
{
if (curves == null || curves.Count == 0)
{
RhinoApp.WriteLine(“No curves provided for dimensioning.”);
return new List();
}

List<LinearDimension> dimensions = new List<LinearDimension>();

// Process each curve individually
foreach (Curve curve in curves)
{
    BoundingBox bbox = curve.GetBoundingBox(true);

    // Skip invalid bounding boxes
    if (!bbox.IsValid)
        continue;

    // Create width dimension (horizontal)
    double width = bbox.Max.X - bbox.Min.X;
    if (width > RhinoMath.ZeroTolerance)
    {
        // Create horizontal dimension below the curve
        Point3d startPt = new Point3d(bbox.Min.X, bbox.Min.Y - spacing,0);
        Point3d endPt = new Point3d(bbox.Max.X, bbox.Min.Y - spacing,0);
        Point3d dimLinePt = new Point3d(bbox.Max.X, bbox.Max.Y + spacing ,0);

        // Create dimension line
        LinearDimension widthDim = LinearDimension.Create(AnnotationType.Aligned, doc.DimStyles.Current, Plane.WorldXY, new Vector3d(1, 0, 0), startPt, endPt, dimLinePt, 0);
        widthDim.TextHeight = dimensionFontSize;
        widthDim.DimensionStyle.TextGap = dimensionFontSize * 0.5;
        widthDim.DimensionStyle.ArrowLength = dimensionFontSize * 1.5;

        // Add dimension to result
        dimensions.Add(widthDim);
    }

    // Create height dimension (vertical)
    double height = bbox.Max.Y - bbox.Min.Y;
    if (height > RhinoMath.ZeroTolerance)
    {
      
        // Create vertical dimension to the right of the curve
        Point3d startPt = new Point3d(bbox.Max.X + spacing, bbox.Min.Y,0);
        Point3d endPt = new Point3d(bbox.Max.X + spacing, bbox.Max.Y,0);
        Point3d dimLinePt = new Point3d(bbox.Max.X + spacing * 1.5, (bbox.Min.Y + bbox.Max.Y) / 2,0);
       
        // Create dimension line
        LinearDimension heightDim =LinearDimension.Create(AnnotationType.Aligned, doc.DimStyles.Current, Plane.WorldXY,new Vector3d(0,1,0), startPt, endPt, dimLinePt, Math.PI/2);
        heightDim.TextHeight = dimensionFontSize;
        heightDim.DimensionStyle.TextGap = dimensionFontSize * 0.5;
        heightDim.DimensionStyle.ArrowLength = dimensionFontSize * 1.5;
        heightDim.TextRotation = Math.PI/2; // Rotate text to be more readable
     
        dimensions.Add(heightDim);
    }
}



return dimensions;

}

I believe the text is controlled by the style used on it, so you may need to change the Text Style to achieve what you need

Thank you for your reply. If you have something more specific, I will give that a go. I have been trying many different things, such as “heightDim.DimensionStyle.DimTextOrientation= TextOrientation.InView;”, and heightDim.DimensionStyle.DimTextOrientation= 0;" and “heightDim.DimensionStyle.DimTextOrientation = 0;”. I have also tried Math.PI/2 in place of zero, on all things, and out of desperation. Ill keep watching, and looking for myself. Thank you for the help.