在下想将与多段线相交的圆删除,总是不理想,请高手帮忙看下!感激不尽!
Document doc = Application.DocumentManager.MdiActiveDocument;Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
TypedValueList value1 = new TypedValueList();
value1.Add(typeof(Circle));
SelectionFilter filter1 = new SelectionFilter(value1);
PromptSelectionResult psr1 = ed.GetSelection(filter1);
if (psr1.Status != PromptStatus.OK)
{ return; }
SelectionSet ss1 = psr1.Value;
TypedValueList value2 = new TypedValueList();
value2.Add(typeof(Polyline));
SelectionFilter filter2 = new SelectionFilter(value2);
PromptSelectionResult psr2 = ed.GetSelection(filter2);
if (psr2.Status != PromptStatus.OK)
{ return; }
SelectionSet ss2 = psr2.Value;
ObjectIdCollection obc1 = new ObjectIdCollection();
foreach (ObjectId id1 in ss1.GetObjectIds())
{
obc1.Add(id1);
}
ObjectIdCollection obc2 = new ObjectIdCollection();
foreach (ObjectId id2 in ss2.GetObjectIds())
{
obc2.Add(id2);
}
Point3dCollection intpoints = new Point3dCollection ();
intm = 2;int n = -2;
ObjectIdCollection obc = new ObjectIdCollection();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
for (int i = 0; i < obc1.Count; i++)
{
Circle cir = trans.GetObject(obc1, OpenMode.ForRead) as Circle;
for (int j = 0; j < obc2.Count; j++)
{
Polyline pl = trans.GetObject(obc2, OpenMode.ForRead) as Polyline;
pl.IntersectWith(cir, Intersect.OnBothOperands, intpoints,m, n);
//Point3d pt = cir.Center;
//pl.GetDistAtPoint(pt)<cir.Radius
if (intpoints.Count>0)
{
obc.Add(cir.ObjectId);
//cir.Erase(true);
}
}
}
for (int i = 0; i < obc.Count;i++ )
{
Circle ci = trans.GetObject(obc, OpenMode.ForWrite) as Circle;
ci.Erase(true);
}
trans.Commit();
}
}
点pline->取模拟点->由点表构造过滤器为Circle的 F 选择
页:
[1]