using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using System.IO;
using System.Collections;
using Autodesk.AutoCAD.Internal;
namespace pavli
{
public class pavli
{
[CommandMethod("PAVLI")]
public void PAVLI()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
LayoutManager layMng = LayoutManager.Current;
List<Autodesk.AutoCAD.DatabaseServices.Polyline> lin2 = new List<Autodesk.AutoCAD.DatabaseServices.Polyline>();
List<double> lst1 = new List<double> { 210, 297, 420, 594, 841, 1100, 1188, 1600, 1261, 1783, 1330, 2380 };
string curLayoutName1 = layMng.CurrentLayout;
TypedValue[] acTypValAr1 = new TypedValue[1];
//acTypValAr.SetValue(new TypedValue(67, 1), 0);
acTypValAr1.SetValue(new TypedValue(410, curLayoutName1), 0);
acTypValAr1.SetValue(new TypedValue((int)DxfCode.Start, "POLYLINE,LWPOLYLINE"), 0);
SelectionFilter acSelFtr1 = new SelectionFilter(acTypValAr1);
PromptSelectionResult acSSPrompt1 = ed.SelectAll(acSelFtr1);
if (acSSPrompt1.Status == PromptStatus.OK && acSSPrompt1.Value.Count > 0)
{
//SelectionSet acSSet1 = acSSPrompt1.Value;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
//ObjectId csId = db.CurrentSpaceId;
//BlockTableRecord cs = tr.GetObject(csId, OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId id in acSSPrompt1.Value.GetObjectIds())
{
// // выбираем все линии по параметрам
// foreach (ObjectId id in cs)
//{
// //if (id.ObjectClass.Name == "AcDbPolyline")
// if (id.ObjectClass.DxfName == "LWPOLYLINE")
// //if (id.ObjectClass.IsDerivedFrom(RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline))))
// {
Autodesk.AutoCAD.DatabaseServices.Polyline plln = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Polyline;
foreach (double dbl1 in lst1)
{
if (plln.Length == dbl1) lin2.Add(plln);
}
}
tr.Commit();
}
}
ed.WriteMessage("\nКоличество полилиний" + lin2.Count);
}
}
}