1 public static ObjectId[] GetBo(double x, double y)
2 {
3
4 ObjectId[] objss;//这是文本对象的ID数组
5
6 ArrayList arr = new ArrayList();
7
8 Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
9
10 TypedValue[] val = new TypedValue[]
11 {new TypedValue (0,"TEXT") };//需要筛选的类型值
12 SelectionFilter fil = new SelectionFilter(val);//选择过滤器
13 PromptSelectionResult pro = ed.SelectAll(fil);//获取结果
14 SelectionSet ss = pro.Value;//赋值给选择集
15
16 objss = ss.GetObjectIds();//将选择集内对象ID赋值给ID数组
17
18 for (int i = 0; i < objss.Length; i++)
19 {
20 //通过getdbject可以对文字对象进行读取
21 DBText buftext = GetDBObject(objss[i]) as DBText;//遍历数组ID将对象赋值给单行文本
22 Point3d po = buftext.Position;//获取单行文本的坐标点
23 if (getDistance(po.X, po.Y, x, y) < 2.5)
24 {
25 //将符合条件的文字放在数组中
26 arr.Add(objss[i]);//将所筛选出的单行文本对象放在数组中
27 }
28 }
29
30 ObjectId[] objs = new ObjectId[arr.Count];//筛选后的文字ID数组
31
32 for (int i = 0; i < arr.Count; i++)
33 {
34 //遍历集合获取他们的ID信息
35 object a = arr[i];
36
37 objs[i] = (ObjectId)a;
38 }
39
40 return objs;
41 }