Exemple #1
0
        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);
        }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        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();
            }
        }