示例#1
0
        public void CDS_RenumberPoint()
        {
            PromptIntegerResult result = _editor.GetInteger(
                "\nEnter point to renumber:");

            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            uint currentPointNumber = (uint)result.Value;

            result = _editor.GetInteger("\nEnter new point number (hint):");
            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            uint pointNumberHint = (uint)result.Value;

            try
            {
                CogoPointCollection points  = _civildoc.CogoPoints;
                ObjectId            pointId =
                    points.GetPointByPointNumber(currentPointNumber);
                points.SetPointNumber(pointId, getNextPointNumberAvailable(pointNumberHint));
            }
            catch (ArgumentException ex)
            {
                _editor.WriteMessage(ex.Message);
            }
        }
示例#2
0
        public void CDS_CreateRandomPointsAtSpecifiedNumberByFactor()
        {
            PromptIntegerResult result = _editor.GetInteger(
                "\nEnter number of points to generate: ");

            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            int numberOfPoints = result.Value;

            result = _editor.GetInteger(
                "\nEnter base number for first point: ");
            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            uint basePoint = (uint)result.Value;

            ObjectIdCollection createdIds = createPoints(numberOfPoints);
            uint firstCreatedPointNumber  = getPointNumberFor(createdIds[0]);
            int  additiveFactor           = (int)(basePoint - firstCreatedPointNumber);
            CogoPointCollection points    = _civildoc.CogoPoints;

            points.SetPointNumber(ToEnumerable(createdIds), additiveFactor);
        }
示例#3
0
        getPointByNumber(this uint pntNum)
        {
            ObjectId            idCgPnt = ObjectId.Null;
            CivilDocument       civDoc  = CivilApplication.ActiveDocument;
            CogoPointCollection cgPnts  = civDoc.CogoPoints;

            idCgPnt = cgPnts.GetPointByPointNumber(pntNum);
            return(idCgPnt);
        }
示例#4
0
        [CommandMethod("CCPFE_XYZ")] //CCPFE = CreateCogoPointsFromExcel

        static public void CCPFE_XYZ()
        {
            Document      doc  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            CivilDocument Cdoc = CivilApplication.ActiveDocument;
            Editor        ed   = doc.Editor;
            Database      db   = doc.Database;

            double wallThk = 0.3;
            double baseThk = 0.3;

            string[,] data = LoadExcel(getFolderPath());
            for (long i = 1; i < data.GetLength(0); i++)
            {
                double x = Convert.ToDouble(data[i, 4]);
                double y = Convert.ToDouble(data[i, 5]);
                double z = Convert.ToDouble(data[i, 6]);

                CogoPointCollection cogoPoints = Cdoc.CogoPoints;
                ObjectId            pointId    = cogoPoints.Add(new Point3d(x, y, z), true);

                //reverse the angle direction, this input is from 12d
                double rotationAng = -degreeToRad(Convert.ToDouble(data[i, 11]));
                cogoPoints.SetMarkerRotation(pointId, rotationAng);

                //check, this needed to be unique.
                string name = data[i, 2];
                cogoPoints.SetPointName(pointId, name);

                string rawName = data[i, 1];
                cogoPoints.SetRawDescription(pointId, rawName);

                //double scaler = 1.1;
                //cogoPoints.SetScaleXY(pointId, scaler);
            }

            ////start a transaction
            //using (Transaction trans = db.TransactionManager.StartTransaction())
            //{

            //    // All points in a document are held in a CogoPointCollection object
            //    // We can access CogoPointCollection through the CivilDocument.CogoPoints property

            //    CogoPointCollection cogoPoints = CivilApplication.ActiveDocument.CogoPoints;

            //    // Adds a new CogoPoint at the given location with the specified description information
            //    ObjectId pointId = cogoPoints.Add(location, "Survey Point");
            //    CogoPoint cogoPoint = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;

            //    // Set Some Properties
            //    cogoPoint.PointName = "Survey_Base_Point";
            //    cogoPoint.RawDescription = "This is Survey Base Point";

            //    trans.Commit();
            //}
        }
示例#5
0
        private void renumberPoints(ObjectIdCollection pointIds, uint basePoint)
        {
            CogoPointCollection points = _civildoc.CogoPoints;
            uint suggested             = basePoint;

            foreach (ObjectId pointId in pointIds)
            {
                suggested = getNextPointNumberAvailable(suggested);
                points.SetPointNumber(pointId, suggested);
                suggested++;
            }
        }
示例#6
0
        public void CDS_OffsetPointElevations()
        {
            PromptDoubleResult result = _editor.GetDouble(
                "\nEnter elevation offset: ");

            if (result.Status == PromptStatus.OK)
            {
                double offset = result.Value;
                CogoPointCollection points = _civildoc.CogoPoints;
                points.SetElevationByOffset(points, offset);
            }
        }
示例#7
0
        private ObjectIdCollection createPoints(int numberOfPoints)
        {
            RandomCoordinateGenerator generator =
                new RandomCoordinateGenerator();
            Point3dCollection coordinates =
                generator.GetCoordinates(numberOfPoints);
            CogoPointCollection points = _civildoc.CogoPoints;

            _creationSet++;
            string description = String.Format("Creation {0}", _creationSet);

            return(points.Add(coordinates, description));
        }
示例#8
0
        public void CDS_CreateCivilDevPoints()
        {
            RandomCoordinateGenerator generator =
                new RandomCoordinateGenerator();
            CogoPointCollection points = _civildoc.CogoPoints;

            Point3dCollection coordinates = generator.GetCoordinates(10);

            points.Add(coordinates, "TREE MAPLE", true, true);

            coordinates = generator.GetCoordinates(10);
            points.Add(coordinates, "WELL DEEP", true, true);
        }
        public static Dictionary <string, object> geolocationCapture(CogoPointCollection passedCogoCollection)
        {
            var doc  = Application.DocumentManager.MdiActiveDocument;
            var acDB = doc.Database;

            // Creat a json file of the Corner Record Points found in the CogoPointCollection
            // Retrieves the Long/Lat of the Point and converts to decimal degrees
            // Confirms that the Name field is filled correctly (cr x)

            using (var trans = acDB.TransactionManager.StartTransaction())
            {
                Dictionary <string, object> cogoPointJson = new Dictionary <string, object>();

                foreach (ObjectId cogoPointRecord in passedCogoCollection)
                {
                    CogoPoint cogoPointItem = trans.GetObject(cogoPointRecord, OpenMode.ForRead) as CogoPoint;

                    Match cogoMatch = Regex.Match(cogoPointItem.PointName, "^(\\s*cr\\s*\\d\\d*)$",
                                                  RegexOptions.IgnoreCase);

                    if (cogoMatch.Success)
                    {
                        Dictionary <String, object> cogoPointGeolocation = new Dictionary <string, object>();

                        //convert the Lat/Long from Radians to Decimal Degrees
                        double rad2DegLong = (cogoPointItem.Longitude * 180) / Math.PI;
                        double rad2DegLat  = (cogoPointItem.Latitude * 180) / Math.PI;

                        cogoPointGeolocation.Add("Corner_Type_c", "Other");
                        cogoPointGeolocation.Add("Geolocation_Longitude_s", rad2DegLong);
                        cogoPointGeolocation.Add("Geolocation_Latitude_s", rad2DegLat);
                        cogoPointGeolocation.Add("Full Description", cogoPointItem.FullDescription);

                        cogoPointJson.Add(cogoPointItem.PointName.Trim().ToString().ToLower().Replace(" ", ""),
                                          cogoPointGeolocation);
                    }
                }

                using (var writer = File.CreateText("CogoPointsGeolocation.json"))
                {
                    string strResultJson = JsonConvert.SerializeObject(cogoPointJson,
                                                                       Formatting.Indented);
                    writer.WriteLine(strResultJson);
                }
                trans.Commit();

                return(cogoPointJson);
            }
        }
示例#10
0
        [CommandMethod("gsi")] //Comanda revizuita care importa puncte din fisiere gsi
        public void ImportGSI()
        {
            //Selectia fisierelor gsi
            Document      acadDoc  = Application.DocumentManager.MdiActiveDocument;
            CivilDocument civilDoc = CivilApplication.ActiveDocument;
            Editor        ed       = acadDoc.Editor;
            Database      db       = HostApplicationServices.WorkingDatabase;

            PromptOpenFileOptions POFO = new PromptOpenFileOptions("Select gsi file: ");

            POFO.Filter = ".gsi";

            PromptFileNameResult FileRes = ed.GetFileNameForOpen(POFO);

            if (FileRes.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\nFile selection failed! Aborting.");
                return;
            }
            string cale = FileRes.StringResult;

            PromptResult PSR = ed.GetString("\nSpecify points description");

            if (PSR.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\nInvalid description! Aborting.");
                return;
            }
            string descriere = PSR.StringResult;

            String3D listaPuncte = new String3D();

            listaPuncte.ImportGSI(cale);

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                CogoPointCollection cogoPoints = civilDoc.CogoPoints;
                foreach (Punct3D punct in listaPuncte)
                {
                    ObjectId  pointId = cogoPoints.Add(new Point3d(punct.X, punct.Y, punct.Z));
                    CogoPoint cogo    = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;
                    cogo.RawDescription = descriere;
                }
                trans.Commit();
            }
        }
示例#11
0
        public static void EditCogoPoints()
        {
            Editor ed = Active.Active.Editor;

            // Select the location for COGO Point

            PromptPointOptions ppo = new PromptPointOptions("\nSelect the location to Create a COGO Point :");

            PromptPointResult ppr = ed.GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            Point3d location = ppr.Value;

            //start a transaction

            using (Transaction trans = Active.Active.StartTransaction())
            {
                // All points in a document are held in a CogoPointCollection object

                // We can access CogoPointCollection through the CivilDocument.CogoPoints property

                CogoPointCollection cogoPoints = CivilApplication.ActiveDocument.CogoPoints;

                // Adds a new CogoPoint at the given location with the specified description information

                ObjectId pointId = cogoPoints.Add(location, "Survey Point", true);

                CogoPoint cogoPoint = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;

                // Set Some Properties

                if (cogoPoint != null)
                {
                    cogoPoint.PointName = "Survey_Base_Point";

                    cogoPoint.RawDescription = "This is Survey Base Point";
                }

                trans.Commit();
            }
        }
示例#12
0
        public void CDS_CreateRandomPoints()
        {
            RandomCoordinateGenerator generator =
                new RandomCoordinateGenerator();
            CogoPointCollection points = _civildoc.CogoPoints;

            // From Point3d
            Point3d  coordinate = generator.GetCoordinate();
            ObjectId pointId    = points.Add(coordinate);

            write("\nSingle Point from coordinate.");
            display(pointId);

            coordinate = generator.GetCoordinate();
            pointId    = points.Add(coordinate, "Sample description.");
            write("\nSingle Point from coordinate and description.");
            display(pointId);

            coordinate = generator.GetCoordinate();
            pointId    = points.Add(coordinate, "Sample description",
                                    true, false);
            write("\nSingle Point from coordinate with description, "
                  + "using description key, and not matching parameters.");
            display(pointId);

            // From Point3dCollection
            Point3dCollection  coordinates = generator.GetCoordinates(10);
            ObjectIdCollection pointIds    = points.Add(coordinates);

            write("\nPoints from coordinate collection.");
            display(pointIds);

            coordinates = generator.GetCoordinates(5);
            pointIds    = points.Add(coordinates, "Group of 5");
            write("\nPoints from coordinate collection with description.");
            display(pointIds);

            coordinates = generator.GetCoordinates(7);
            pointIds    = points.Add(coordinates, "Group of 7", true, true);
            write("\nPoints from coordinate collection with description,"
                  + "using description key, and not matching parameters.");
            display(pointIds);
        }
示例#13
0
        private uint getNextPointNumberAvailable(uint hint)
        {
            uint suggested             = hint;
            CogoPointCollection points = _civildoc.CogoPoints;

            while (points.Contains(suggested) && suggested < _maxPointNumber)
            {
                suggested++;
            }

            if (suggested == _maxPointNumber)
            {
                string msg = String.Format(
                    "No available point number at {0} or greater value.",
                    hint);
                throw new ArgumentException(msg);
            }

            return(suggested);
        }
示例#14
0
文件: Stake_Util.cs 项目: 15831944/EM
        getBegPntNum()
        {
            long        pntNumBeg     = 0;
            List <long> pntNums       = null;
            List <long> pntNumsSorted = new List <long>();

            CogoPointCollection idPnts = CivilApplication.ActiveDocument.CogoPoints;

            foreach (ObjectId idPnt in idPnts)
            {
                pntNums.Add((long)idPnt.getCogoPntNumber());
            }

            if (pntNums.Count == 0)
            {
                pntNumBeg = 30000;
            }
            else
            {
                var sortPntNums = from p in pntNums
                                  orderby p ascending
                                  select p;

                foreach (var p in sortPntNums)
                {
                    pntNumsSorted.Add(p);
                }

                int k = pntNumsSorted.Count;

                if (pntNumsSorted[k - 1] < 30000)
                {
                    pntNumBeg = 30000;
                }
                else if (pntNumsSorted[0] > 30000)
                {
                    pntNumBeg = pntNumsSorted[k - 1];
                }
            }
            return((uint)pntNumBeg);
        }
示例#15
0
        [CommandMethod("convacadpts")] //Comanda pentru convertirea punctelor autocad in puncte COGO de civil3d
        public void ConvAcadPts()
        {
            CivilDocument civDoc = CivilApplication.ActiveDocument;
            Database      db     = HostApplicationServices.WorkingDatabase;
            Editor        ed     = Application.DocumentManager.MdiActiveDocument.Editor;

            //Selectia punctelor autocad
            PromptSelectionOptions PrSelOpt = new PromptSelectionOptions();

            PrSelOpt.MessageForAdding  = "\nSelect points to add: ";
            PrSelOpt.MessageForRemoval = "\nSelect points to remove: ";

            TypedValue[]    tvs = { new TypedValue((int)DxfCode.Start, "POINT") };
            SelectionFilter sf  = new SelectionFilter(tvs);

            PromptSelectionResult PrSelRes = ed.GetSelection(PrSelOpt, sf);

            if (PrSelRes.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\nInvalid Selection! Aborting.");
                return;
            }

            //Solicitarea descrierii punctelor COGO
            string descriere = ed.GetString("\nSpecify points description: ").StringResult;

            //Creearea puntelor COGO
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                CogoPointCollection cogoPoints = civDoc.CogoPoints;
                foreach (SelectedObject selObj in PrSelRes.Value)
                {
                    Autodesk.AutoCAD.DatabaseServices.DBPoint punctAcad = (Autodesk.AutoCAD.DatabaseServices.DBPoint)trans.GetObject(selObj.ObjectId, OpenMode.ForRead);
                    ObjectId  pointId = cogoPoints.Add(punctAcad.Position);
                    CogoPoint cogo    = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;
                    cogo.RawDescription = descriere;
                }
                trans.Commit();
            }
        }
示例#16
0
        public void CDS_NaiveRenumberPoint()
        {
            PromptIntegerResult result = _editor.GetInteger(
                "\nEnter point to renumber:");

            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            uint currentPointNumber = (uint)result.Value;

            result = _editor.GetInteger("\nEnter new point number:");
            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            uint newPointNumber = (uint)result.Value;

            CogoPointCollection points  = _civildoc.CogoPoints;
            ObjectId            pointId = points.GetPointByPointNumber(currentPointNumber);

            points.SetPointNumber(pointId, newPointNumber);
        }
示例#17
0
文件: CgPnts.cs 项目: 15831944/EM
        getNextPointNumber(uint lowLim, uint uppLim)
        {
            uint pntNum = 0;
            CogoPointCollection idsPnts = BaseObjs._civDoc.CogoPoints;
            List <uint>         pntNums = new List <uint>();

            foreach (ObjectId id in idsPnts)
            {
                CogoPoint cgPnt = (CogoPoint)id.getEnt();
                pntNums.Add(cgPnt.PointNumber);
            }

            var sortNums = from n in pntNums
                           orderby n descending
                           select n;

            foreach (var n in sortNums)
            {
                pntNum = n;
                break;
            }

            return(pntNum + 1);
        }
        public static void ImportJobPoints()
        {
            var      doc = AcApp.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            var           jobNumber = Functions.GetJobNumber(doc);
            SelectionForm form      = new SelectionForm(jobNumber);
            var           ret       = AcApp.ShowModalDialog(form);

            if (ret == DialogResult.Cancel)
            {
                ed.WriteMessage("Job import canceled by user.");
                return;
            }
            else
            {
                ed.WriteMessage($"Import Job list: Count - {form.SelectedFiles.Count} | Filtered - {form.FilterPoints} | X-ref attach - {form.AttachXref}" + Environment.NewLine);
                List <List <C3DPoint> > pointList = IntFunctions.ProcessFiles(form.SelectedFiles);

                //Actually do the things
                using (Transaction trans = ed.Document.Database.TransactionManager.StartTransaction())
                {
                    List <CogoPoint> existingPoints = new List <CogoPoint> {
                    };
                    CogoPointCollection cogoPoints  = CivilApplication.ActiveDocument.CogoPoints;
                    foreach (var cogoPointObj in cogoPoints)
                    {
                        CogoPoint cogoPointItem = cogoPointObj.GetObject(OpenMode.ForWrite) as CogoPoint;
                        existingPoints.Add(cogoPointItem);
                    }

                    string confirmed = "";

                    for (int i = 0; i < pointList.Count; i++)
                    {
                        var points     = pointList[i];
                        int pointcount = 0;
                        foreach (var newPoint in points)
                        {
                            if (existingPoints.Where(pn => pn.PointNumber == newPoint.PointNumber).Count() == 0)
                            {
                                Point3d   point   = newPoint.Coordinate;
                                ObjectId  pointId = cogoPoints.Add(point, false);
                                CogoPoint cogop   = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;
                                cogop.PointNumber    = newPoint.PointNumber;
                                cogop.RawDescription = newPoint.Decsription;
                                cogop.StyleId        = ObjectId.Null;
                                cogop.LabelStyleId   = ObjectId.Null;
                                existingPoints.Add(cogop);
                                confirmed += $"{newPoint.PointNumber}, ";
                                pointcount++;
                            }
                            else
                            {
                                /*if (points.Where(pn => pn.RawDescription == (string)newPoint[4]).Count() == 0)
                                 * {
                                 *  MessageBox.Show("A point with a conflicting point number was detected. You can renumber this.");
                                 * }
                                 * else
                                 * {
                                 *  MessageBox.Show("A point with a conflicting point number and description was detected. Ingoring a duplicate point");
                                 * }*/
                            }
                        }
                        //TODO: Add more fuctionality to point group.

                        string filename = Path.GetFileNameWithoutExtension(form.SelectedFiles[i]);
                        ed.WriteMessage($"Successfully imported {pointcount} points." + Environment.NewLine);
                        if (form.AttachXref)
                        {
                            string folder  = Path.GetDirectoryName(form.SelectedFiles[i]);
                            string CADFile = Path.Combine(folder, filename + ".dwg");
                            if (File.Exists(Path.Combine(folder, filename + ".dwg")))
                            {
                                //Getting the layer object
                                LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite);
                                if (!lt.Has("G-HH-XREF"))
                                {
                                    LayerTableRecord ltr = new LayerTableRecord
                                    {
                                        Name     = "G-HH-XREF",
                                        Color    = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 7),
                                        IsFrozen = false,
                                        ViewportVisibilityDefault = true
                                    };

                                    ObjectId ltId = lt.Add(ltr);
                                    trans.AddNewlyCreatedDBObject(ltr, true);
                                }

                                var xId = db.AttachXref(CADFile, filename);
                                if (xId.IsValid)
                                {
                                    var btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                                    var br  = new BlockReference(Point3d.Origin, xId)
                                    {
                                        Layer = "G-HH-XREF"
                                    };
                                    btr.AppendEntity(br);
                                    trans.AddNewlyCreatedDBObject(br, true);
                                }
                            }
                            ed.WriteMessage($"Successfully attached {filename} CAD file." + Environment.NewLine);
                        }
                    }

                    PointGroupCollection pointGroups = CivilApplication.ActiveDocument.PointGroups;
                    string groupName = "Group Import " + DateTime.Now.ToString("MM-dd-yy");
                    if (!pointGroups.Contains(groupName))
                    {
                        ObjectId pointGroup           = pointGroups.Add(groupName);
                        StandardPointGroupQuery query = new StandardPointGroupQuery
                        {
                            IncludeNumbers = confirmed
                        };
                        PointGroup group = (PointGroup)pointGroup.GetObject(OpenMode.ForWrite);
                        group.SetQuery(query);
                    }

                    /*foreach (var newPoint in newPoints)
                     * {
                     *  if (points.Where(pn => pn.PointNumber == (uint)newPoint[0]).Count() == 0)
                     *  {
                     *      Point3d point = new Point3d((double)newPoint[2], (double)newPoint[1], (double)newPoint[3]);
                     *      ObjectId pointId = cogoPoints.Add(point, false);
                     *      CogoPoint cogop = pointId.GetObject(OpenMode.ForWrite) as CogoPoint;
                     *      cogop.PointNumber = (uint)newPoint[0];
                     *      cogop.RawDescription = (string)newPoint[4];
                     *      points.Add(cogop);
                     *  }
                     *  else
                     *  {
                     *      if (points.Where(pn => pn.RawDescription == (string)newPoint[4]).Count() == 0)
                     *      {
                     *          MessageBox.Show("A point with a conflicting point number was detected. You can renumber this.");
                     *      }
                     *      else
                     *      {
                     *          MessageBox.Show("A point with a conflicting point number and description was detected. Ingoring a duplicate point");
                     *      }
                     *  }
                     * }*/
                    object acad = AcApp.AcadApplication;
                    acad.GetType().InvokeMember("ZoomExtents", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, acad, null);
                    trans.Commit();
                }
            }

            Logging.LogEntry(jobNumber, "POINT IMPORT", "Points were added to drawing.");

            form.Dispose();
            ed.Regen();
        }
示例#19
0
        //[CommandMethod("AddDataToSurfaces")]
        /// <summary>
        /// Adding data from PlanFeatures (character lines) to surfaces and also inser PointsCogoGrous to surfaces
        /// </summary>
        /// <param name="midOrdinate"></param>
        /// <param name="maxDist"></param>
        /// <param name="weedingDist"></param>
        /// <param name="weedingAngle"></param>
        public static void AddDataToSurfaces(double midOrdinate = 0.1, double maxDist = 10.0, double weedingDist = 0.1, double weedingAngle = 0.5)
        {
            //Document doc = doc_dyn.AcDocument;
            var      CivilApp = CivilApplication.ActiveDocument;
            Document doc      = Application.DocumentManager.MdiActiveDocument;
            Database db       = doc.Database;
            Editor   ed       = doc.Editor;

            //double midOrdinate = 0.1; double maxDist = 10.0; double weedingDist = 0.1; double weedingAngle = 0.5; -- if start as CommandMethod
            using (Transaction ts = db.TransactionManager.StartTransaction())
            {
                try
                {
                    foreach (ObjectId OneSiteItem in CivilApp.GetSiteIds())
                    {
                        Site   OneSite   = ts.GetObject(OneSiteItem, OpenMode.ForRead) as Site;
                        string Site_Name = OneSite.Name;
                        //ed.WriteMessage("\n Site_Name =" + Site_Name);

                        foreach (ObjectId OneSurfaceId in CivilApp.GetSurfaceIds())
                        {
                            //ObjectId SurfaceId = new ObjectId();
                            TinSurface CurrentSurface = ts.GetObject(OneSurfaceId, OpenMode.ForWrite) as TinSurface;
                            //ed.WriteMessage("\n OneSurf.Name =" + CurrentSurface.Name);
                            if (CurrentSurface.Name == Site_Name)
                            {
                                ed.WriteMessage($"\n Site with surface's name {CurrentSurface.Name} is exist!");
                                //ed.WriteMessage("\n Start adding standard breaklines for " + CurrentSurface.Name);
                                AddBreakLines(null);
                                //ed.WriteMessage("\n Start adding point group for " + CurrentSurface.Name);
                                AddPointsGroup();
                                //ed.WriteMessage("\n Start adding out boundary for " + CurrentSurface.Name);
                                AddBreakLines("Out_Boundary");
                                //ed.WriteMessage("\n Start adding internal boundary for " + CurrentSurface.Name);
                                AddBreakLines("Internal_Boundary");
                                CurrentSurface.Rebuild();
                                ed.WriteMessage("\n Start rebuilding for " + CurrentSurface.Name);

                                void AddBreakLines(string TypeOfLines)
                                {
                                    ObjectIdCollection GroupOfBreaklines = new ObjectIdCollection();

                                    foreach (ObjectId OneFlineItem in OneSite.GetFeatureLineIds())
                                    {
                                        FeatureLine OneFline      = ts.GetObject(OneFlineItem, OpenMode.ForRead) as FeatureLine;
                                        string      OneFline_Name = OneFline.Name;

                                        if (OneFline_Name.Contains("outer_") && TypeOfLines == "Out_Boundary")
                                        {
                                            ed.WriteMessage("\n Start adding outer boundary for " + OneFline_Name);
                                            CurrentSurface.BoundariesDefinition.AddBoundaries(OneFline.GetPoints(Autodesk.Civil.FeatureLinePointType.AllPoints), midOrdinate, Autodesk.Civil.SurfaceBoundaryType.Outer, true);
                                        }
                                        else if (OneFline_Name.Contains("void_") && TypeOfLines == "Internal_Boundary")
                                        {
                                            ed.WriteMessage("\n Start adding internal boundary for " + OneFline_Name);
                                            CurrentSurface.BoundariesDefinition.AddBoundaries(OneFline.GetPoints(Autodesk.Civil.FeatureLinePointType.AllPoints), midOrdinate, Autodesk.Civil.SurfaceBoundaryType.Hide, true);
                                        }
                                        else
                                        {
                                            GroupOfBreaklines.Add(OneFlineItem);
                                        }
                                    }
                                    if (TypeOfLines == null)
                                    {
                                        ed.WriteMessage("\n Start adding standard breaklines");
                                        CurrentSurface.BreaklinesDefinition.AddStandardBreaklines(GroupOfBreaklines, midOrdinate, maxDist, weedingDist, weedingAngle);
                                    }
                                }

                                void AddPointsGroup()
                                {
                                    CogoPointCollection CG_AllPoints = CivilApp.CogoPoints;

                                    foreach (ObjectId OneCogoItem in CG_AllPoints)
                                    {
                                        CogoPoint  COGO_Single = ts.GetObject(OneCogoItem, OpenMode.ForRead) as CogoPoint;
                                        ObjectId   CG_GroupId  = COGO_Single.PrimaryPointGroupId;
                                        PointGroup CG_Group    = ts.GetObject(CG_GroupId, OpenMode.ForRead) as PointGroup;
                                        if (CG_Group.Name == Site_Name)
                                        {
                                            ed.WriteMessage("\n COGO points group for surface's name was find - it's name = " + CG_Group.Name);
                                            CurrentSurface.PointGroupsDefinition.AddPointGroup(CG_GroupId);
                                            break;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                catch (System.Exception e)
                {
                    ed.WriteMessage(e.Message);
                }

                ts.Commit();
            }
        }
示例#20
0
        getDesignPoints(ObjectId idAlign, ref List <POI> varPOI, string strSide)
        {
            List <POI> varPOI_PNTs = new List <POI>();
            POI        vPOI_PNT    = default(POI);

            vPOI_PNT       = new POI();
            vPOI_PNT.Desc0 = "NOTHING";
            varPOI_PNTs.Add(vPOI_PNT);

            double dblStation = 0;
            double dblOffset  = 0;

            double dblToleranceLength = 0;

            short i = 0;
            short k = 0;

            bool boolAdd = false;

            CogoPointCollection objCogoPnts = BaseObjs._civDoc.CogoPoints;

            k = -1;

            foreach (ObjectId idCogoPnt in objCogoPnts)
            {
                CogoPoint objCogoPnt = (CogoPoint)idCogoPnt.getEnt();

                boolAdd = false;

                try {
                    try {
                        idAlign.getAlignStaOffset(objCogoPnt.Location, ref dblStation, ref dblOffset);
                    }
                    catch (Autodesk.Civil.PointNotOnEntityException) {
                        dblStation = 0.0;
                    }

                    if (strSide == "LEFT")
                    {
                        if (dblOffset > dblToleranceLength * -1 & dblOffset < 0)
                        {
                            boolAdd = true;
                        }
                    }
                    else if (strSide == "RIGHT")
                    {
                        if (dblOffset > 0 & dblOffset < dblToleranceLength)
                        {
                            boolAdd = true;
                        }
                    }
                    else if (strSide == "BOTH")
                    {
                        if (System.Math.Abs(dblOffset) < dblToleranceLength)
                        {
                            boolAdd = true;
                        }
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex) {
                    boolAdd = false;
                    Debug.Print(ex.ToString());
                }

                if (boolAdd == true)
                {
                    vPOI_PNT           = new POI();
                    vPOI_PNT.Station   = Base_Tools45.Math.roundDown3(dblStation);
                    vPOI_PNT.PntNum    = objCogoPnt.PointNumber.ToString();
                    vPOI_PNT.Elevation = System.Math.Round(objCogoPnt.Elevation, 3);

                    try {
                        idAlign.getAlignStaOffset(objCogoPnt.Location, ref dblStation, ref dblOffset);
                    }
                    catch (Autodesk.Civil.PointNotOnEntityException) {
                        dblStation = 0.0;
                    }

                    vPOI_PNT.OFFSET    = System.Math.Round(dblOffset, 2);
                    vPOI_PNT.Desc0     = string.Format("{0} {1}", varPOI_PNTs[k].OFFSET, varPOI_PNTs[k].Elevation);
                    vPOI_PNT.PntSource = "GCAL";

                    varPOI_PNTs.Add(vPOI_PNT);
                }

                objCogoPnt.Dispose();
            }

            dynamic stations = from data in varPOI_PNTs
                               orderby data.Station
                               select data;
            List <POI> p = new List <POI>();

            foreach (var d in stations)
            {
                p.Add(d);
            }
            varPOI_PNTs = p;

            Misc.removeDuplicatePoints(ref varPOI_PNTs);

            if (varPOI_PNTs.Count > 0)
            {
                for (i = 0; i < varPOI_PNTs.Count; i++)
                {
                    varPOI.Add(varPOI_PNTs[i]);
                }
            }

            dynamic staPOI = from data in varPOI
                             orderby data.Station
                             select data;

            p = new List <POI>();
            foreach (var d in staPOI)
            {
                p.Add(d);
            }

            if (varPOI.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#21
0
        stakeGridPoints(ObjectId idAlign, List <POI> varPOI_STAKE, double staBeg = 0, double staEnd = 0, int side = 0, long begNum = 30000)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();
            double    dblStation = 0, dblOffset = 0;

            if ((side == 0))
            {
                if (double.Parse(fGrid.tbxOffsetH.Text) != 0)
                {
                    PromptStatus ps;
                    bool         escape = true;

                    Point3d varPntPick = UserInput.getPoint("Select side to place stake points: <ESC to Cancel>", Pub.pnt3dO, out escape, out ps, osMode: 8);
                    if (escape)
                    {
                        return;
                    }

                    objAlign.StationOffset(varPntPick.X, varPntPick.Y, ref dblStation, ref dblOffset);

                    if (System.Math.Abs(dblOffset) > 20.0)
                    {
                        DialogResult varResponse = MessageBox.Show(string.Format("\nPoint selected is more than 20' from Alignment: {0} \nContinue?", objAlign.Name, MessageBoxButtons.YesNo));

                        if (varResponse == DialogResult.No)
                        {
                            return;
                        }
                    }
                    if (dblOffset < 0)
                    {
                        side = -1;
                    }
                    else
                    {
                        side = 1;
                    }
                    fStake.Side = side;
                }
                else
                {
                    fStake.Side = 1;
                }
            }
            else
            {
                fStake.Side = side;
            }

            fStake.STAKE_LAYER = fGrid.tbxOffsetH.Text + "-OS-" + objAlign.Name;

            dblOffset = double.Parse(fGrid.tbxOffsetH.Text);
            string strName = fStake.NameStakeObject;

            double dblStaBeg = Math.roundDown3((objAlign.StartingStation));
            double dblStaEnd = Math.roundDown3((objAlign.EndingStation));

            uint lngPntNumBeg = Stake_Util.getBegPntNum();

            fStake.NextPntNum = lngPntNumBeg;

            CogoPointCollection cgPnts = CivilApplication.ActiveDocument.CogoPoints;

            fStake.POI_STAKED = new List <POI>();

            //**********PROCESS varPOI_STAKE*********************
            for (int i = 0; i <= varPOI_STAKE.Count; i++)
            {
                if (varPOI_STAKE[i].DescX == "")
                {
                    POI vPOI_STAKE = varPOI_STAKE[i];
                    vPOI_STAKE.DescX = vPOI_STAKE.Desc0;
                    varPOI_STAKE[i]  = vPOI_STAKE;
                }

                if (i == varPOI_STAKE.Count - 1)
                {
                    break;
                }

                double dblElev = varPOI_STAKE[i].Elevation;

                switch (varPOI_STAKE[i].Desc0)
                {
                case "AP":

                    switch (side)
                    {
                    case 1:
                        //right side

                        //counterclockwise
                        if (varPOI_STAKE[i].isRightHand)
                        {
                            if (fGrid.optPBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            else if (fGrid.optRBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT_RBC(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            //clockwise
                        }
                        else
                        {
                            Stake_Calc.doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                        }

                        break;

                    case -1:
                        //left side

                        //counterclockwise
                        if (varPOI_STAKE[i].isRightHand)
                        {
                            Stake_Calc.doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            //clockwise
                        }
                        else
                        {
                            if (fGrid.optPBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            else if (fGrid.optRBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT_RBC(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                        }

                        break;
                    }

                    break;

                default:

                    string strDesc = varPOI_STAKE[i].DescX;
                    double dblEasting = 0, dblNorthing = 0;
                    try
                    {
                        objAlign.PointLocation(varPOI_STAKE[i].Station, dblOffset * side, ref dblEasting, ref dblNorthing);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        try
                        {
                            objAlign.PointLocation(varPOI_STAKE[i].Station - 0.01, dblOffset * side, ref dblEasting, ref dblNorthing);
                        }
                        catch (IndexOutOfRangeException)
                        {
                            objAlign.PointLocation(varPOI_STAKE[i].Station + 0.01, dblOffset * side, ref dblEasting, ref dblNorthing);
                        }
                    }

                    Point3d dblPnt = new Point3d(dblEasting, dblNorthing, varPOI_STAKE[i].Elevation);

                    string strOffset = dblOffset.ToString();
                    Stake_Calc.setOffsetPoint(dblPnt, strOffset, strName, strDesc, idAlign, varPOI_STAKE[i].Station);

                    break;
                }
            }

            List <POI> varPOI_STAKED = fStake.POI_STAKED;
            int        k             = varPOI_STAKED.Count - 1;

            uint lngPntNumEnd = uint.Parse(varPOI_STAKED[k].PntNum);

            TypedValue[] tvs = new TypedValue[4] {
                new TypedValue(1001, "STAKE"),
                new TypedValue(1071, lngPntNumBeg),
                new TypedValue(1071, lngPntNumEnd),
                new TypedValue(1000, fStake.STAKE_LAYER)
            };

            idAlign.setXData(tvs, "STAKE");

            CgPnt_Group.updatePntGroup("SPNT");

            Stake_UpdateProfile.updateProfile(idAlign, (fStake.POI_STAKED), "STAKE", true, "STAKED");

            bool     exists = false;
            ObjectId idDict = Dict.getNamedDictionary("STAKE_PNTS", out exists);

            List <Point3d> dblPnts = new List <Point3d>();
            Point3d        pnt3d   = Pub.pnt3dO;

            for (int p = 0; p < varPOI_STAKED.Count; p++)
            {
                ObjectId idPnt = BaseObjs._civDoc.CogoPoints.GetPointByPointNumber(uint.Parse(varPOI_STAKED[p].PntNum));
                pnt3d = idPnt.getCogoPntCoordinates();
                dblPnts.Add(pnt3d);
                ResultBuffer rb = new ResultBuffer {
                    new TypedValue(1000, idPnt.getCogoPntNumber().ToString()),
                    new TypedValue(1005, idPnt.getHandle().ToString())
                };
                Dict.addXRec(idDict, idPnt.ToString(), rb);
            }

            dblPnts.Add(dblPnts[0]);
            Draw.addPoly(dblPnts, fStake.STAKE_LAYER, 9);

            Misc.logUsage("STAKE", (lngPntNumEnd - lngPntNumBeg + 1));
        }
示例#22
0
        processCutsheetData(string strSource)
        {
            List <CmdControls> cCntls     = fExport.cntls;
            List <DataSet>     varDataSet = fExport.dataSet;
            List <DataSet>     varDataSum = fExport.dataSum;

            System.Windows.Forms.Button cmdBtn = default(System.Windows.Forms.Button);

            List <ObjectId> objCutSheetPnts = new List <ObjectId>();
            List <uint>     lngPntNums      = new List <uint>();

            uint lngPntNum = 0;

            CogoPointCollection objPnts = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument.CogoPoints;
            ObjectId            objPnt  = ObjectId.Null;

            List <string> strLayers = new List <string>();

            switch (strSource)
            {
            case "EXPORTPOINTS":

                for (int i = 0; i < cCntls.Count; i++)
                {
                    if (cCntls[i].chkBox1.Checked)
                    {
                        strLayers.Add(cCntls[i].chkBox1.Text);

                        cmdBtn = cCntls[i].cmdBtn;

                        switch (cmdBtn.Text.Substring(11, 3))
                        {
                        case "SRT":
                            varDataSet = fExport.dataSet;
                            lngPntNums = varDataSet[i].Nums;
                            break;

                        case "SUM":
                            varDataSum = fExport.dataSum;
                            lngPntNums = varDataSum[i].Nums;
                            break;
                        }

                        //do partial
                        if (cCntls[i].chkBox2.Checked)
                        {
                            for (int j = int.Parse(cCntls[i].tBxLowerB.Text); j <= int.Parse(cCntls[i].tBxUpperB.Text); j++)
                            {
                                for (int k = 0; k < lngPntNums.Count; k++)
                                {
                                    lngPntNum = lngPntNums[k];
                                    if ((uint)j == lngPntNum)
                                    {
                                        try
                                        {
                                            objPnt = objPnts.GetPointByPointNumber(lngPntNum);
                                            objCutSheetPnts.Add(objPnt);
                                        }
                                        catch (System.Exception)
                                        {
                                        }

                                        break;
                                    }
                                }
                            }

                            //do full list
                        }
                        else
                        {
                            for (int k = 0; k < lngPntNums.Count; k++)
                            {
                                lngPntNum = lngPntNums[k];
                                try
                                {
                                    objPnt = objPnts.GetPointByPointNumber(lngPntNum);
                                    objCutSheetPnts.Add(objPnt);
                                }
                                catch (System.Exception)
                                {
                                }
                            }
                        }
                    }
                }

                break;

            case "POINTLIST":

                for (int j = 0; j < fPoints.lbxPoints.CheckedItems.Count; j++)
                {
                    lngPntNum = (uint)fPoints.lbxPoints.Items[j];
                    try
                    {
                        objPnt = objPnts.GetPointByPointNumber(lngPntNum);
                        objCutSheetPnts.Add(objPnt);
                    }
                    catch (System.Exception)
                    {
                    }
                }
                fPoints.Hide();
                break;
            }

            Microsoft.Office.Interop.Word.Document objCutSheet      = setupCutSheet(strLayers);
            Microsoft.Office.Interop.Word.Table    objCutSheetTable = objCutSheet.Tables[2];

            if (addCutSheetData(objCutSheetTable, objCutSheetPnts))
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Cutsheet created at: " + objCutSheet.Path + "\\" + objCutSheet.Name);
            }
            else
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Cutsheet operation failed - check if points were selected.....");
            }
        }