Display Pipeline and DrawText

I am trying to draw text in a Display Pipeline. This much I have achieved, DrawText takes a TextEntity and a colour. However, this method only seems to draw Text at a Height of 1 and I cannot seem to change this. The TextEntities I am feeding in have heights ranging from 0.5 to 32 and yet all are the same size and scale when shown in the Pipeline.

I have tried using Draw2dText but this creates text that scales with the view, they are however relative to each other, the correct scale, but I need my text to be the correct size at all zoom levels. I even tried finding the ratio of zoom in the view so I could correct them by dynamically changing the scale, but this has also proved fruitless.

I know I could resort to converting the Text Entities to curves or surfaces and displaying/scaling those, however when I print they would not be selectable as text.

TL;DR;
Does anyone have any idea how to display text in the pipeline at the real scale of the TextEntity I am trying to feed in?

– Callum

It seems that the TextEntity is driven entirely from the AnnotationStyle. Changing the alignment/height/font is all directly related to that. Which also explains why Alignment would not display correctly.

1 Like

I found when I scaled the text that it would move it off into the distance. I also found when I tried to move it back it was not linear. By Scaling the text and then translating it proportional to its scale it placed and scaled correctly. The below example is how I got it to work.

TextEntity tent;
Color colour = Color.Red;

Point3d p1 = new Point3d(0, 0, 0);
Point3d p2 = tent.Plane.Origin;

// This makes correct height but locates it at 0,0,0
Transform scale = Transform.Scale(new Point3d(0, 0, 0), tent.Height);
Vector3d translation = new Vector3d(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z)
Transform mover = Transform.Translation(translation/tent.Height);
Transform transforms = Transform.Multiply(scale, mover);

e.Display.DrawText(tent, colour, transforms);

– Callum

1 Like