Community
I let user select a dbText, and I would like to retrieve all dbText objects whose content is equal to the selected on.
Thanks,
Solved! Go to Solution.
Solved by SENL1362. Go to Solution.
Suppose this is part of youre drawing with TEXT(DBText not MTEXT) entities,
Then this code fragment:
string textPattern = ".*World"; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); var matchingText = ms.Cast<ObjectId>() .Where(id => id.ObjectClass.DxfName.ToUpper() == "TEXT") .Select(id => (DBText)tr.GetObject(id, OpenMode.ForRead)) .Where(txt => Regex.IsMatch(txt.TextString,textPattern,RegexOptions.IgnoreCase)) .ToList(); matchingText.ForEach(txt => ed.WriteMessage("\n Matching Text== '{0}'", txt.TextString)); tr.Commit(); }
will find:
Matching Text== 'Hello World!'