Example #1
0
        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);
        }
Example #2
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);
        }
Example #3
0
        internal void BuildPolygons(System.Windows.Controls.ProgressBar progressBar)
        {
            using (var trans = Ac.StartTransaction())
                try
                {
                    progressBar.Maximum = Lines.Count;
                    progressBar.Minimum = 0;

                    foreach (var ln in Lines)
                    {
                        Polyline polyline = new Polyline();
                        polyline.AddVertex(ln.StartPoint);
                        if (BuildPolygon(polyline, ln.StartPoint, ln))
                        {
                            polyline.Closed = true;
                            if (polyline.NumberOfVertices > 2)
                            {
                                trans.AddEntity(polyline);
                            }
                        }
                        progressBar.Value = progressBar.Value + 1;
                        System.Windows.Forms.Application.DoEvents();
                    }
                    trans.Commit();
                }
                catch (System.Exception ex)
                {
                    Ac.WriteLn("Geo7: " + ex.Message);
                }
        }
Example #4
0
File: Ac.cs Project: 15831944/Geo7
 /// <summary>
 /// If there is no value for 'name' empty string ("") is returned.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static string GetValue(string name)
 {
     using (var docLoc = Ac.Doc.LockDocument())
         using (var trans = Ac.StartTransaction())
         {
             return(trans.GetValue(name));
         }
 }
Example #5
0
File: Ac.cs Project: 15831944/Geo7
 public static void SetValue(string name, string value)
 {
     using (var docLoc = Ac.Doc.LockDocument())
         using (var trans = Ac.StartTransaction())
         {
             trans.SetValue(name, value);
             trans.Commit();
         }
 }
Example #6
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();
            }
        }
Example #7
0
File: Ac.cs Project: 15831944/Geo7
        public static SortedSet <string> GetBlockNames(bool onlyWithReferences, bool onlyWithAttributes)
        {
            var res = new SortedSet <string>();

            using (var trans = Ac.StartTransaction())
            {
                var dbBlocks = trans.BlockDefs.AsEnumerable();
                if (onlyWithReferences)
                {
                    dbBlocks = dbBlocks.Where(b => b.HasReferences);
                }
                if (onlyWithAttributes)
                {
                    dbBlocks = dbBlocks.Where(b => b.HasAttributes);
                }

                res.AddItems(dbBlocks.Select(b => b.Name));
            }
            return(res);
        }
Example #8
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();
            }
        }