Well, if you don want to loop through entire ModelSpace for certain type of entities, you can use Editor.SelectAll(SelectionSetFilter filter), something like:
var vals = TypedValue[]
{
new TypedValue((int)DxfCode.Start, "TEXT"),
new TypedValue((int)DxfCode.LayoutName, "MODEL")
};
var res=activeDocument.Editor.SelelctAll(new SelectionSetFilter(vals));
if (res.Status==PromptStatus.OK)
{
using (var tran=.....)
{
foreach (var id in res.Value.GetObjectIds())
{
var textEntity=(DbText)tran.GetObject(id, OpenMode.ForRead);
......
//comparing DbText's TextString with the text to be searched for here
}
tran.Commit()
}
}
In reality, looping through entire ModelSpace may not be as bad/as slow in comparison to getting a filtered SelectionSet, as one thinks, depending on drawing. And sometimes, the fraction of second difference is ignorable