OpenNurbs v 7.0

I see that there is a large difference between v 6.0 Font management and v 7
Now I am a bit lost since I need to generate a series of text with specified height (in mm)
but I am unable to see how to do this.

It was quite simple in v 6

	ON_TextEntity2  *pent = new ON_TextEntity2 (  );
	pent->SetType( ON::dtTextBlock);

Can I have a hint for v 7.0 ?


Try this:

  const wchar_t* textstring = L"New text";
  const double textheight = 3.7;
  const ON_Plane plane;
  // You can use any dimstyle.
  // Passing nullptr for tjhe style will use ON_DimStyle::Default
  // If the text height and whatever else you want to tune up is set 
  // in the style you use, you don't have to set it after creating the text.
  // If you do set properties after creating the text, they will be set as overrides
  const ON_DimStyle* style = nullptr;
  ON_Text* ontext = new ON_Text;
  ontext->Create(textstring, style, plane);
  ontext->SetTextHeight(style, textheight);
1 Like

Thanks Lowell , works fine
Now the question is How to make a Dimstyle ?
I need to change a few properties but I don’t really understand where does the dimstyle
go, I don’t want to generate a dimstyle for each text generated, but only one dimstyle
and assign it to the text objects.
Basically I want to create a new dimstyle by copy of a default one and use it for all my font objects
that share same attributes. I see all the routines but a bit confused


Ok Forget my question I see that the text objects has all overrides

fine thanks

Hi Lowell
There seems to be a bug on the text orientation, after calling this code
in the image you can see the point passed and the final text position
aligned on top instead of the bottom

	if (text->Create(sztext, refDim, plane))
		text->SetAlignment(ON::TextHorizontalAlignment::Left, ON::TextVerticalAlignment::Bottom);
		text->SetTextHeight(refDim, FontH);


@gerryark - You can use
ontext->SetTextVerticalAlignment(style, ON::TextVerticalAlignment::Bottom);
I’ll see if I can figure out about SetAlignment(). I think it should be deprecated.