如何快速选择与一条多段线相交的线?
我想选择出某一图层中与一条多段线相交的多段线或二维多段线,该怎么写选择条件呢?我现在的方法是:
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
TypedValue value1 = new TypedValue((int)DxfCode.Start, "*PolyLine");
TypedValue value2 = new TypedValue((int)DxfCode.LayerName, Layername);
TypedValue[] values = { value1, value2 };
SelectionFilter sfilter = new SelectionFilter(values);
PromptSelectionResult resSel = ed.SelectAll(sfilter);
SelectionSet sSet = resSel.Value;
ObjectId[] ids = sSet.GetObjectIds();
Polyline polylineTemp = new Polyline(2);
polylineTemp.AddVertexAt(0, p1, 0, 0, 0);
polylineTemp.AddVertexAt(1, p2, 0, 0, 0);
using (Transaction trans = db.TransactionManager.StartTransaction())
{
foreach(ObjectId sSetEntId in ids)
{
Entity myEntity = (Entity)trans.GetObject(sSetEntId, OpenMode.ForRead);
if ((myEntity is Polyline) || (myEntity is Polyline2d))
{
//这里做myEntity 与polylineTemp 是否有交点的判断
}
}
trans.commit();
}
系统自带的EXPREES tools工具
不是有FS命令吗 用SelectFence Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Entity entity = null;
DBObjectCollection dbCollection = new DBObjectCollection();
TypedValue [] type=newTypedValue;
type = new TypedValue((int)DxfCode.Start, "*PolyLine");
type = new TypedValue((int)DxfCode.LayerName, layerName);
// 表示得到所有与多边形相交的对象,并且该对象所在layerName层的曲线
PromptSelectionResult ents = ed.SelectFence(pts,filter);//pts要相交的多段线的合
if (ents.Status == PromptStatus.OK)
{
SelectionSet ss = ents.Value;
using (Transaction tran = db.TransactionManager.StartOpenCloseTransaction())
{
foreach (ObjectId id in ss.GetObjectIds())
{
entity = tran.GetObject(id, OpenMode.ForWrite, true) as Entity;
if (entity != null)
{
dbCollection.Add(entity); //得到的对象放入集合中
}
tran.Commit();
}
}
}
希望能帮到你。。 chengw 发表于 2011-9-26 14:29 static/image/common/back.gif
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Applicat ...
请问pts怎么定义啊~
页:
[1]