- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2015-3-30 21:36:10
|
显示全部楼层
本帖最后由 雪山飞狐_lzh 于 2015-3-30 21:37 编辑
好像想多了 如果不复杂的话 用组就可以了
我的测试结果。。。总在不停的崩溃
[CommandMethod("t10")]
public static void Test10()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
ed.SelectionAdded -= new SelectionAddedEventHandler(ed_SelectionAdded);
ed.SelectionAdded += new SelectionAddedEventHandler(ed_SelectionAdded);
}
static void ed_SelectionAdded(object sender, SelectionAddedEventArgs e)
{
if (e.Flags == SelectionFlags.PickfirstSet)
{
Editor ed = (Editor)sender;
Document doc = ed.Document;
Database db = doc.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
foreach (SelectedObject selobj in e.AddedObjects)
{
Line line = tr.GetObject(selobj.ObjectId, OpenMode.ForRead) as Line;
if (line != null)
{
var res = ed.SelectAll(
new ResultTree
{
{0, "circle"},
new ResultTree("or")
{
{10, line.StartPoint},
{10, line.EndPoint}
}
});
if (res.Status == PromptStatus.OK)
{
foreach (SelectedObject obj in res.Value)
e.Add(obj);
}
}
}
}
}
}
|
|