- [CommandMethod("tta")]
- public static void tta()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- var res =
- ed.SelectAll(
- new SelectionFilter(
- new TypedValue[]
- {
- new TypedValue(0, "LWPOLYLINE")
- }));
- if (res.Status != PromptStatus.OK)
- return;
- double totalArea = 0;
- using (var tr = db.TransactionManager.StartTransaction())
- {
- foreach(var id in res.Value.GetObjectIds())
- {
- var pl = tr.GetObject(id, OpenMode.ForRead) as Polyline;
- totalArea += pl.Area;
- }
- }
- ed.WriteMessage("\ntotal area is {0}", totalArea);
- }
|