复制代码LoopList类在这里找
测试代码:
-
- [CommandMethod("t4")]
- public static void Test4()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
-
- PromptEntityOptions optsEnt = new PromptEntityOptions("\nSelect a LWPolyLine:");
- optsEnt.SetRejectMessage("\nNot a LWPolyLine!");
- optsEnt.AddAllowedClass(typeof(LWPolyline), false);
- PromptEntityResult resEnt = ed.GetEntity(optsEnt);
- if (resEnt.Status == PromptStatus.OK)
- {
- Database db = doc.Database;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- LWPolyline pl = tr.GetObject(resEnt.ObjectId, OpenMode.ForRead) as LWPolyline;
- var ptlst =
- Enumerable
- .Range(0, pl.NumberOfVertices)
- .Select(i => pl.GetPoint2dAt(i));
- PromptPointOptions optPnt = new PromptPointOptions("\nInput a Point:");
- optPnt.AllowNone = true;
- PromptPointResult resPnt = ed.GetPoint(optPnt);
- while (resPnt.Status == PromptStatus.OK)
- {
- var res = ptlst.PointOnRegion(resPnt.Value.Convert2d(new Plane()));
- ed.WriteMessage("\nPoint:{0},Result:{1}" ,resPnt.Value, res);
- resPnt = ed.GetPoint(optPnt);
- }
- }
- }
- }
|