DimensionStyle definition

I don’t know how to define the width and height of a text to create curves. Depending on the font used, it seems that the text does not fit in width and writes it vertically.

For example, using font: Machine Tool SanSerif the result is:

And if I change the font by Machine Tool Granadier the result is:

The code to create the curves is like this:

Rhino.Geometry.TextEntity text_entity;

DimensionStyle dimensionStyleChanges = new DimensionStyle();
dimensionStyleChanges.Font = _font;
dimensionStyleChanges.TextHeight = textHeight;
dimensionStyleChanges.TextOrientation = TextOrientation.InPlane;
text_entity = TextEntity.Create(text, Plane.WorldXY, dimensionStyleChanges, true, textHeight, 0);
Curve [ ] curvesArray = text_entity.CreateCurves(text_entity.DimensionStyle, true);

Do I have to modify any more DimensionStyle values?

Thanks

Please, does anyone know how I can solve this?

Hi @Eliseo,

Where can we find the fonts you’ve mentioned?

– Dale

Hi @dale ,

I think my problem is not the font, here are several examples I obtain from other fonts:
Calibri:


Arial:
image
Bahnscrift:

Times New Roman:
image
Tahoma:

I have tested with CreateCurves and CreatePolySurfaces and the result is the same, sometimes all the letters does not fit to a line.

Hi @Eliseo,

Can you provide step-by-step instructions that will allow me to repeat what you are seeing?

– Dale

Hi @dale

Yes, of course. Here you have an example:

public class TestCommand : Rhino.Commands.Command
{
    static TestCommand _instance;
    public TestCommand()
    {
        _instance = this;
    }
    public static TestCommand Instance
    {
        get { return _instance; }
    }

    public override string EnglishName
    {
        get { return "TestCommand"; }
    }

    protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
    {            
        Rhino.DocObjects.DimensionStyle dimensionStyleChanges = new Rhino.DocObjects.DimensionStyle();
         
        Rhino.DocObjects.Font _font = Rhino.DocObjects.Font.FromQuartetProperties("Arial", false, false);

        dimensionStyleChanges.Font = _font;
        dimensionStyleChanges.TextHeight = 20;
        dimensionStyleChanges.TextOrientation = Rhino.DocObjects.TextOrientation.InPlane;

        Rhino.Geometry.TextEntity text_entity;
        text_entity = Rhino.Geometry.TextEntity.Create("Hola", Rhino.Geometry.Plane.WorldXY, dimensionStyleChanges, true, 20, 0);
        Rhino.Geometry.Curve[] curvesArray = text_entity.CreateCurves(text_entity.DimensionStyle, true);

        foreach (Rhino.Geometry.Curve c in curvesArray)
            Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(c);


        _font = Rhino.DocObjects.Font.FromQuartetProperties("Tahoma", false, false);

        dimensionStyleChanges.Font = _font;
        dimensionStyleChanges.TextHeight = 20;
        dimensionStyleChanges.TextOrientation = Rhino.DocObjects.TextOrientation.InPlane;

        text_entity = Rhino.Geometry.TextEntity.Create("Hola", Rhino.Geometry.Plane.WorldXY, dimensionStyleChanges, true, 20, 0);
        curvesArray = text_entity.CreateCurves(text_entity.DimensionStyle, true);

        foreach (Rhino.Geometry.Curve c in curvesArray)
            Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(c);

        Rhino.RhinoDoc.ActiveDoc.Views.Redraw();

        return Rhino.Commands.Result.Success;           
    }

}

Eliseo

Hi @Eliseo,

You might consider creating text curves at a smaller size, perhaps 1.0, and then scaling them as a group to the width you are looking for.

– Dale