Use of Dimension Style not respected in DrawText on Rhino 8

I am using a DisplayConduit to display information to the user which I do not want captured in the Rhino Doc. For a while now we have been telling users to stick to Rhino 7 as the text is not drawn correctly in Rhino 8 (I’ve only now just found the time to diagnose the issue).

The issue as far as I can tell is that we create a DimensionStyle in memory (which is not added to the Document), which contained within a TextEntity which we draw using DrawText within our DisplayConduit, i.e. the sudo code would be

internal record DrawData(IEnumerable<TextEntity> textEntities);

internal class MyLogic
{
    public CreateDrawData(MyModel model)
    {
        var dimStyle = new DimensionStyle()
        {
            TextVerticalAlignment = TextVerticalAlignment.Middle,
            TextHorizontalAlignment = TextHorizontalAlignment.Center,
        }
        // Some logic

        var textEnitities = new List<TextEntity>()
        {
            TextEntity.Create(myText, nyPlane, dimStyle, false, 0, 0);
        }

        return new DrawData(text);
    }
}

internal class MyConduit : DisplayConduit
{
    public DrawData? Data { get; set; }

    protected override void PreDrawObjects(DrawEventArgs e)
    {
        foreach (var textEntity in Data.TextEntities)
        {
            e.Display.DrawText(textEntity, myColor);
        }
    }    
}

The issue appears to be that the DimensionStyle is not applied. I’m guessing maybe this is due to the fact that it has not been added to the Document (which I would rather not do) as it indicates the DimensionStyle is unset which is expect is because it does not have an index? … I’m guessing.

However, this logic worked perfectly fine in Rhino 7.

I expect one solution for this is just to keep everything as is and unpack the data and use Draw3dText instead, which should work for my case, but I think this is more limited that DrawText

I’ve now tried:

  1. Replacing DrawText with Draw3dText but it appears that there is a significant drop in performance.
  2. Adding the DimStyle to the rhino doc prior to draw calls (no change).

It seems that DrawText may not be working correctly on Rhino 8.

Hi @Mike26,

Can you provide a simple example, that I can run here, of what works in V7 and not in V8?

— Dale

@dale do you want a github repo with a project that can be run, or is some sample code here good enough?

The cheaper the sample the better. Save me some time please.

Thanks,

— Dale

Sample provided here (it’s just a single file). There are some screen shots in the readme.
SoggyBottomBoy/Rhino8DimStyle

Hi @Mike26, What about DrawAnnotation?

https://developer.rhino3d.com/api/rhinocommon/rhino.display.displaypipeline/drawannotation
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.annotationbase

Hi @Mike26,

I can repeat this, and I have logged the regression.

Thanks for reporting.

For now, you might call DisplayPipeline.DrawAnnotation. I have a feeling the dimension style will need to be added to the document (too).

– Dale

1 Like

RH-87220 is fixed in Rhino 8 Service Release 20 Release Candidate