[CommandMethod("Test")]
public void Test()
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo
= new PromptEntityOptions
("\nSelect the first curve: "); peo.SetRejectMessage("Only a curve !");
peo
.AddAllowedClass(typeof(Curve
),
false); PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
ObjectId id1 = per.ObjectId;
peo.Message = "\nSelect the second curve: ";
per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
ObjectId id2 = per.ObjectId;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Curve curve1 = (Curve)tr.GetObject(id1, OpenMode.ForRead);
Curve curve2 = (Curve)tr.GetObject(id2, OpenMode.ForRead);
Point3dCollection pts
= new Point3dCollection
(); curve1.IntersectWith(curve2, Intersect.OnBothOperands, pts, 0, 0);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
foreach (Point3d pt in pts)
{
ed.WriteMessage("\n" + pt.ToString());
Circle c
= new Circle
(pt, Vector3d
.ZAxis,
10.0); ms.AppendEntity(c);
tr.AddNewlyCreatedDBObject(c, true);
}
tr.Commit();
}
}