There are a few examples of identifying EDF in a single textblock using the C++ api, i was hoping someone has done that in the .net api, or could point me in the right direction. I am able to Get Textblock, and create a caret, but how do I get a Run from a caret? Looks like there's Caret.MoveToNextRun, but that doesn't seem to return a run, and Caret.PreviousCharacter and Caret.NextCharacter returns just Char, which isn't going to help me identify if its an EDF or not. Is there another way of stepping through each part of a textblock?
Viktor_Kulik said:There are a few examples of identifying EDF in a single textblock using the C++ api, i was hoping someone has done that in the .net api
The TextBlock API in .NET is incomplete compared to the same API in C++. For example, using the C++ MicroStationAPI you can create a TextField, but that's not available in .NET.
Regards, Jon Summers LA Solutions
I wrote a test code as below to get EDF from text element. It uses several new text related classes, such as ParagraphRange, ParagraphIterator and RunIterator.
private static void GetEDF()
ulong id = 1193;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
Element elem = dgnModel.FindElementById(new ElementId(ref id));
TextQuery txtQuery = TextQuery.GetAsTextQuery(elem);
TextQueryOptions options = new TextQueryOptions();
TextPartIdCollection txtParts = txtQuery.GetTextPartIds(options);
TextBlock txtBlk = txtQuery.GetTextPart(txtParts);
ParagraphRange paraRng = new ParagraphRange(txtBlk);
ParagraphIterator paraIter = paraRng.GetParagraphIterator();
RunIterator runIter = paraIter.GetRunIterator();
Run run = runIter.Current;
EdfCharStream edf = run as EdfCharStream;
bool isEdf = (edf == null) ? false : true;
MessageCenter.Instance.ShowInfoMessage(run.ToString() + ", isEdf =" + isEdf.ToString(), null, false);
My test text is as below:
Output in message center is as below:
I also just write a wiki to discuss what is TextPart as below. The article is in Chinese but I believe google can easily translate it into English.
That looks usable! Thanks Yongan.Fu , so a follow up question on this, using the ParagraphIterator and RunIterator should only be used for understanding the contents of the textblock but not for updating, right? If i need to update part of the EDF i would need to use the TextBlock.Insert.... methods? Is that right?
You are right for all your questions.