- 积分
- 217
- 明经币
- 个
- 注册时间
- 2014-10-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
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 ();
int m = 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[i], OpenMode.ForRead) as Circle;
for (int j = 0; j < obc2.Count; j++)
{
Polyline pl = trans.GetObject(obc2[j], 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[i], OpenMode.ForWrite) as Circle;
ci.Erase(true);
}
trans.Commit();
}
}
|
|