I have the code below working except the textstyle is not applied. The textstyle exists in the active file. Probably something simple that I'm missing.
I've seen the TextStyle.AddToElement(element, key) but have no idea what the "key" parameter is.
private static void PlaceTextElement(string inputString, DPoint3d origin, DgnTextStyle textStyle, string levelName) { DgnModel currentModel = Session.Instance.GetActiveDgnModel(); TextBlock textBlock = new TextBlock(textStyle, currentModel); textBlock.SetUserOrigin(origin); textBlock.AppendText(inputString); TextElement textElement = (TextElement)TextElement.CreateElement(null, textBlock); LevelId levelId = GetLevelIdByLevelName(levelName); ElementPropertiesSetter propSetter = new ElementPropertiesSetter(); propSetter.SetLevel(levelId); propSetter.SetColor(SymbologyValue.ColorByLevel); propSetter.SetWeight(SymbologyValue.WeightByLevel); propSetter.Apply(textElement); textElement.AddToModel(); }
Hi Mike,
I think to define TextStyle in TextBlock constructor is recommended way. So it should work in my opinion.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
For some reason the textstyle is not being applied when I create the textblock. I've verified the textstyle is in the current dgn and the textstyle object I'm passing in the TextBlock is correct. It is just not applied.