Select to view content in your preferred language

Error identifying the font of a TextElement in Dgn File

971
3
09-19-2012 06:02 PM
TaiBui
by
Frequent Contributor
Hi friends,

I am using namespace MicroStationDgn in Visual Studio 2010 to read elements of a file Dgn (created by Microstation Version 7).

I used the below command to try to identify the font of a TextElement:

MessageBox.Show(oScanEnumerator.Current.AsTextElement.TextStyle.Font.Name)

But I got an error: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)

(In actual, this "TextElement" has font: "Vnarial" - Vietnamese font, with ID = 150)

Are there anyone know how to fix this error ?

Thanks and regards,

Tai
Tags (2)
0 Kudos
3 Replies
TaiBui
by
Frequent Contributor
Hi,

I discovered the reason of the error is: no TextStyle was assigned for the Text Element.

But, how can identify the font type of the Text Element (such as: Times New Roman, Bold, size: 15) without using TextStyle  ?

Thanks,
0 Kudos
KevinDunlop
Frequent Contributor
The element might be part of a shared cell in the DWG which will assign the style to the parent element.  Or the text might be set to use level symbology instead of unique symbology.
0 Kudos
TaiBui
by
Frequent Contributor
The element might be part of a shared cell in the DWG which will assign the style to the parent element.  Or the text might be set to use level symbology instead of unique symbology.


Thanks Kevin Dunlop,

After installing necessary font resources into Microstation V8i, I can do that now.

I can get Text Size by this command: oScanEnumerator.Current.AsTextElement.TextStyle.GetTotalTextSize(out totalWidth, out totalHeight);

But, I don't know how to change the above sizes to IFontDisp.Size (because I want to add the text into a mapcontrol).

Are there anyone can help ?

Thanks and regards,
Tai
0 Kudos