public int LoadLinesData() { Lines.Clear(); LinesDict.Clear(); int res = 0; using (var trans = Ac.StartTransaction()) { var acLines = trans.GetAllEntities <Line>(); Ac.InitProgress(AppServices.Strings.LoadingLines, acLines.Count()); foreach (var acLn in acLines) { if (acLn.Length < 0.000001) { continue; } var ln = new AcPolygonSegment(acLn); var lnRev = ln.Reverse(); Lines.Add(ln); LinesDict.AddListItem(ln.StartPoint.Id(), ln); // Trzeba dodać odwrotną linię, bo nie zawsze startPoint jest // z tej strony, z której bym chciał Lines.Add(lnRev); LinesDict.AddListItem(lnRev.StartPoint.Id(), lnRev); res++; Ac.SetProgress(res); } Ac.ClearProgress(); } return(res); }
public int BuildPolygons() { int res = 0; using (var trans = Ac.StartTransaction()) try { Ac.InitProgress(AppServices.Strings.CreatingPolygons, Lines.Count()); foreach (var ln in Lines) { Polyline polyline = new Polyline(); polyline.AddVertex(ln.StartPoint); if (BuildPolygon(polyline, ln.StartPoint, ln)) { res++; polyline.Closed = true; if (polyline.NumberOfVertices > 2) { trans.AddEntity(polyline); } } Ac.ProgressStep(); } Ac.ClearProgress(); trans.Commit(); } catch (System.Exception ex) { Ac.WriteLn("Geo7: " + ex.Message); } return(res); }
public void Run() { using (var trans = Ac.StartTransaction()) { var allTexts = trans.GetAllEntities <DBText>().Where(t => !string.IsNullOrEmpty(t.TextString.Trim())); var polygons = trans.GetAllEntities <Polyline>().Where(p => (p.Closed == true) && (p.Length > 0.01)); Ac.InitProgress(AppServices.Strings.ProcessingData, polygons.Count()); foreach (var p in polygons) { var pTexts = GetTextsInPolygon(p, allTexts); ChangePolygonLayer(trans, p, pTexts); Ac.ProgressStep(); } Ac.ClearProgress(); trans.Commit(); } }
public void Run(IEnumerable <Entity> entities, bool showProgress) { BuildEntitiesDict(entities); if (showProgress) { Ac.InitProgress(AppServices.Strings.DeletingDuplicates, entities.Count()); } foreach (var kv in EntitiesDict) { var ids = kv.Value; var ent = kv.Key; if (ent.IsErased) { continue; } foreach (var id in ids) { var duplEnts = IdsDict.GetList(id); foreach (var duplEnt in duplEnts) { if (duplEnt != ent) { duplEnt.UpgradeOpen(); duplEnt.Erase(); } } } if (showProgress) { Ac.ProgressStep(); } } if (showProgress) { Ac.ClearProgress(); } }
public static void Run() { using (var trans = Ac.StartTransaction()) { var polylines = trans.GetAllEntities <Polyline>(); var polygons = polylines.Where(p => p.Closed == true).ToList(); var polygonsByLength = polygons.ToLookup(p => p.Length.ToString(Ac.LinearPrecisionFormat)); Ac.InitProgress(AppServices.Strings.DeletingDuplicates, polygonsByLength.Count); Ac.WriteLn(AppServices.Strings.DeletingDuplicates); foreach (var polygonsWithLength in polygonsByLength) { var ents = polygonsWithLength.ConvertTo <Entity>(); AcRemoveDuplicatedPolygons rdp = new AcRemoveDuplicatedPolygons(); rdp.Run(ents, false); Ac.ProgressStep(); } Ac.ClearProgress(); trans.Commit(); } }