Esempio n. 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);
        }
Esempio n. 2
0
        private static ObjectId ImportMissedRecord(SymbolTable srcTable, string key, SymbolTable destTable)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("ImportMissedRecord(" + srcTable.GetType().Name + ".key)");
            }

            if (destTable.Has(key))  // It is not missed
            {
                return(destTable[key]);
            }

            if (!srcTable.Has(key))
            {
                throw new KeyNotFoundException("'" + key + "' not found in " + srcTable.GetType().Name);
            }


            Ac.WriteLn("Updating " + destTable.GetType().Name + "...  ");     // Updating BlockTable...

            using (var mapping = new IdMapping())
                using (var sourceIds = new ObjectIdCollection())
                {
                    sourceIds.Add(srcTable[key]);

                    srcTable.Database.WblockCloneObjects(sourceIds, destTable.ObjectId, mapping, DuplicateRecordCloning.Ignore, false);
                    Ac.Write(string.Format("'{0}' added.", key));            // G7-FixedPoint added.

                    return(destTable[key]);
                }
        }
Esempio n. 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);
                }
        }
Esempio n. 4
0
File: Ac.cs Progetto: 15831944/Geo7
        public static void InitProgress(string msg, int stepsCount)
        {
            progressPos     = 0;
            progressPercent = 0;
            progressSteps   = stepsCount;
#if AutoCAD
            Autodesk.AutoCAD.Internal.Utils.SetApplicationStatusBarProgressMeter(msg, 0, 100);
#else
            if (progressSteps > 99)
            {
                Ac.WriteLn(msg + "   0");
            }
#endif
        }
Esempio n. 5
0
File: Ac.cs Progetto: 15831944/Geo7
        public static void ClearProgress()
        {
            try
            {
#if AutoCAD
                Autodesk.AutoCAD.Internal.Utils.RestoreApplicationStatusBar();
#else
                Ac.WriteLn("");
#endif
                DoEvents();
            }
            catch (System.Exception ex)
            {
                Ac.WriteError(ex, "Ac.ClearProgress()", null);
            }
        }
Esempio n. 6
0
File: Ac.cs Progetto: 15831944/Geo7
        internal static void WriteError(System.Exception ex, string methodName, string commandName)
        {
            Ac.WriteLn("");
            Ac.WriteLn("G7 Error: ");

            AppServices.Log.AddLn();
            if (!string.IsNullOrEmpty(commandName))
            {
                AppServices.Log.Add("CommanddName: " + commandName);
                Ac.WriteLn("CommanddName: " + commandName);
            }
            if (!string.IsNullOrEmpty(methodName))
            {
                AppServices.Log.Add("MethodName: " + methodName);
                Ac.WriteLn("MethodName: " + methodName);
            }

            Ac.WriteLn(ex.GetAllMessages());
            AppServices.Log.Add(ex);
        }
Esempio n. 7
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();
            }
        }