测试代码
-
-
- [CommandMethod("CTest")]
- public void test()
- {
- var db = HostApplicationServices.WorkingDatabase;
- var doc = Application.DocumentManager.GetDocument(db);
- var ed = doc.Editor;
- var resEnt = ed.GetEntity("\n请选择优化多段线:");
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Polyline pl = resEnt.ObjectId.GetObject(OpenMode.ForWrite) as Polyline;
- var pnts =GetAll(0, pl.NumberOfVertices - 1, i => pl.GetPoint2dAt(i));
- ed.WriteMessage("\n面积:{0}\n顺时针:{1}", pnts.GetArea(), pnts.IsClockWise());
- tr.Commit();
- }
- }
- public IEnumerable GetAll(int start, int end, Func[i] func)
- {
- for (int i = start; i <= end; i++)
- {
- yield return func(i);
- }
- }
-
效果:
命令: ctest
请选择优化多段线:
面积:304398.872847913
顺时针:False
|