Esempio n. 1
0
        public static Collection <List <Logs> > GetReportsToWrite()
        {
            TransformReports report = new TransformReports();

            try
            {
                using (DatabaseCommands commands = new DatabaseCommands())
                {
                    var logs   = commands.GetLastAllLogs();
                    var errors = report.FiltersCombinedAllErrors(logs.ToList());

                    return(errors);
                }
            }
            catch (System.Exception ex)
            {
                COMS.LogException(ex);
            }
            return(null);
        }
Esempio n. 2
0
        public void GetReports()
        {
            TransformReports report = new TransformReports();

            try
            {
                using (DatabaseCommands commands = new DatabaseCommands())
                {
                    var logs   = commands.GetLastAllLogs();
                    var errors = report.FiltersCombinedAllErrors(logs.ToList());

                    foreach (var items in errors)
                    {
                        report.WriteReport(items);
                    }
                }
            }
            catch (System.Exception ex)
            {
                COMS.LogException(ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes the duplicate surfaces by using Layer Rank.
        /// </summary>
        public static void RemoveDuplicateSurfaces_V1()
        {
            try
            {
                COMS.AddLog("Entering Remove Duplicate Surfaces V1!");
                DatabaseCommands commands    = new DatabaseCommands();
                var excludedpolys            = new List <Handle>();
                ObjectIdCollection polylines = null;
                //var features = commands.GetAllFeatures();
                #region Testing for Opening DWGs
                //var filename = OpenDwg.file;
                //Document doc = Application.DocumentManager.Open(filename, true);
                //Application.DocumentManager.MdiActiveDocument = doc;
                //var db = doc.Database;
                //var ed = doc.Editor;
                #endregion

                Document doc = Application.DocumentManager.MdiActiveDocument;
                global::Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database;

                using (doc.LockDocument())
                {
                    using (var trans = db.TransactionManager.StartTransaction())
                    {
                        PGA.SimplifyPolylines.Commands.SimplifyPolylinesTest();

                        //polylines = SelectPolylines.GetAllPolylines();
                        polylines = ACADUTIL.GetAllObjectIdsInModel(db, trans, false);

                        foreach (ObjectId master in polylines)
                        {
                            var masterArea = SelectPolylines.GetPolyLineArea(master, db);
                            foreach (ObjectId comparer in polylines)
                            {
                                //cannot be identical oids
                                if (master.Equals(comparer))
                                {
                                    continue;
                                }

                                //get areas of polys
                                var comparerArea = SelectPolylines.GetPolyLineArea(comparer, db);

                                System.Diagnostics.Debug.WriteLine(String.Format
                                                                       ("M={0},C={1}", masterArea, comparerArea));

                                if (comparerArea == null || masterArea == null)
                                {
                                    continue;
                                }

                                //Precision is set to < 0.5 Sq-ft Missed Features
                                //Precision is set to = 1.0 Sq-ft Works(Not Perfect)

                                if (IsEqual(masterArea, comparerArea, 1.0))
                                {
                                    System.Diagnostics.Debug.WriteLine(String.Format("Entering Equals--> M={0},C={1}",
                                                                                     masterArea, comparerArea));
                                    var masterLayer   = SelectPolylines.GetPolyLineObject(master, db).Layer;
                                    var comparerLayer = SelectPolylines.GetPolyLineObject(comparer, db).Layer;

                                    //Get Rank and exclude secondary poly
                                    if (commands.GetFeatureRankByCode(masterLayer) >
                                        commands.GetFeatureRankByCode(comparerLayer))
                                    {
                                        //exclude comparer layer
                                        excludedpolys.Add(master.Handle);
                                        COMS.AddLog(String.Format(
                                                        "Exclude Master by Layer Rank = CL={0},CA={1}, MA={2} ML={3} ",
                                                        comparerLayer, comparerArea, masterArea, masterLayer));
                                    }
                                }
                            }
                        }
                        trans.Commit();
                    }
                    commands.ClearExcludedFeatures();

                    foreach (var id in excludedpolys)
                    {
                        commands.InsertToExcludedFeatures(id.ToString());
                    }
                }
                COMS.AddLog("Exiting Remove Duplicate Surfaces V1!");
            }
            catch (Exception ex)
            {
                COMS.LogException(ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Removes the duplicate surfaces by using additional filtering.
        /// looking for isolated polylines with no internal objects
        /// on same layer.
        /// </summary>
        public static void RemoveDuplicateSurfaces_V2()
        {
            try
            {
                COMS.AddLog("Entering Remove Duplicate Surfaces V2!");
                DatabaseCommands commands = new DatabaseCommands();
                // var filename = OpenDwg.file;
                ObjectIdCollection polylines = null;
                var excludedpolys            = new List <Handle>();
                //var features = commands.GetAllFeatures();

                #region For Testing Open File
                //Document doc = OpenDwg.OpenDwgForWork(filename);
                //Application.DocumentManager.MdiActiveDocument = doc;
                //var db = doc.Database;
                //var ed = doc.Editor;

                #endregion

                Document doc = Application.DocumentManager.MdiActiveDocument;
                global::Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database;

                using (doc.LockDocument())
                {
                    using (var trans = db.TransactionManager.StartTransaction())
                    {
                        polylines = ACADUTIL.GetAllObjectIdsInModel(db, trans, false);
                        ObjectId MaxORO = GetLargestAreaOfORO(polylines, db);
                        ObjectId MinOCO = GetSmallestAreaOfOCO(polylines, db);
                        ObjectId MinOIR = GetSmallestAreaOfOIR(polylines, db);

                        foreach (ObjectId master in polylines)
                        {
                            var masterpolyline = SelectPolylines.GetPolyLineObject(master, db);
                            var masterArea     = SelectPolylines.GetPolyLineArea(master, db);

                            foreach (ObjectId comparer in polylines)
                            {
                                //cannot be identical oids

                                if (master.Equals(comparer))
                                {
                                    continue;
                                }

                                //get areas of polys

                                var comparerpolyline = SelectPolylines.GetPolyLineObject(comparer, db);
                                var comparerArea     = SelectPolylines.GetPolyLineArea(comparer, db);

                                System.Diagnostics.Debug.WriteLine(String.Format("M={0},C={1}", masterArea, comparerArea));

                                if (comparerArea == null || masterArea == null)
                                {
                                    continue;
                                }

                                //Get Internal Polylines to Interate

                                var IsInternal = PointInPolyline(ACADUTIL.GetPointsFromPolyline(masterpolyline),
                                                                 ACADUTIL.GetPointsFromPolyline(comparerpolyline));

                                if ((masterArea > comparerArea) && IsInternal)
                                {
                                    System.Diagnostics.Debug.WriteLine(String.Format
                                                                           ("We are Internal! M={0},C={1}", masterArea, comparerArea));

                                    // Does master have any internals on same layer
                                    // We are looking for isolated polylines with no internal objects
                                    // on same layer.

                                    var masterLayer   = SelectPolylines.GetPolyLineObject(master, db).Layer;
                                    var comparerLayer = SelectPolylines.GetPolyLineObject(comparer, db).Layer;

                                    //filter out largest ORO polyline
                                    if (masterLayer == "ORO" && master.Equals(MaxORO))
                                    {
                                        continue;
                                    }
                                    if (masterLayer == "OCO" && master.Equals(MinOCO))
                                    {
                                        excludedpolys.Add(master.Handle);
                                        continue;
                                    }
                                    #region Removed-5.14.16
                                    //if (masterLayer == "OIR" && master.Equals(MinOIR))
                                    //{
                                    //    excludedpolys.Add(master.Handle);
                                    //    continue;
                                    //}
                                    #endregion
                                    //continue searching if has internal with same layer
                                    #region Exclude matching layers

                                    if (masterLayer.Equals(comparerLayer))
                                    {
                                        continue;
                                    }

                                    #endregion
                                    #region Add Additional Rank Filtering
                                    //If Green and Fairway, then exclude it!
                                    int Green    = 1;
                                    int Fairway  = 3;
                                    int IntRough = 21;

                                    //Get Rank and exclude secondary poly
                                    int masterRank = commands.GetFeatureRankByCode(masterLayer);
                                    int comparRank = commands.GetFeatureRankByCode(comparerLayer);
                                    COMS.AddLog(String.Format(
                                                    "Debugging = ML={0},CL={1}, MR={2} CR={3} ",
                                                    masterLayer, comparerLayer, masterRank, comparRank));

                                    if (masterRank == IntRough)
                                    {
                                        continue;
                                    }

                                    if ((masterRank > comparRank) &&
                                        (masterRank > 10) &&
                                        (comparRank == Green ||
                                         comparRank == Fairway))

                                    {
                                        //exclude master layer
                                        excludedpolys.Add(master.Handle);
                                        COMS.AddLog(String.Format(
                                                        "Exclude Comparer by Layer Filtering = {0},{1}, MA={2} ML={3} ",
                                                        comparerLayer, comparerArea, masterArea, masterLayer));
                                    }

                                    #endregion
                                }
                            }
                        }
                        trans.Commit();
                    }
                    foreach (var id in excludedpolys)
                    {
                        commands.InsertToExcludedFeatures(id.ToString());
                    }
                }
                COMS.AddLog("ExitingRemove Duplicate Surfaces V2!");
            }
            catch (Exception ex)
            {
                COMS.LogException(ex);
            }
        }