我要做的操作是:获得一些单行文本,并针对这些单行文本的X货Y坐标(用row_conl控制)进行排序。
以下我写的代码:
-
- DBText ch_txt = new DBText();
- DBText ad_txt = new DBText();
- List<DBText> text = new List<DBText>();
- PromptSelectionResult sel = ed.GetSelection(selop, filter2);
- if (sel.Status == PromptStatus.OK)
- {
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- foreach (ObjectId BlockId in sel.Value.GetObjectIds())
- {
- //获取选择集里块里面的对象
- ch_txt=trans.GetObject(BlockId, OpenMode.ForRead) as DBText;
- ad_txt = new DBText();
- ad_txt.TextString = ch_txt.TextString;
- ad_txt.Position = ch_txt.Position;
- text.Add(ad_txt);
- }
- trans.Commit();
- }
- if (row_conl == true)
- text.OrderBy(t => t.Position.Y);
- else
- text.OrderBy(t => t.Position.X);
可是每次运行均未排序。求大神们解惑答疑。
|