Пример #1
0
        makeSurface(string strSurfaceName)
        {
            SelectionSet objSSet = EW_Utility1.buildSSet2a(strSurfaceName);

            if (objSSet == null || objSSet.Count == 0)
            {
                return;
            }

            ObjectId[]         ids     = objSSet.GetObjectIds();
            ObjectIdCollection idsBrks = new ObjectIdCollection();

            foreach (ObjectId id in ids)
            {
                idsBrks.Add(id);
            }

            EW_CheckSurfaceStyles.checkSurfaceStyles(strSurfaceName);

            TinSurface objSurface = Surf.getTinSurface(strSurfaceName);

            if (objSurface == null)
            {
                return;
            }
            objSurface.ObjectId.delete();

            objSurface = Surf.addTinSurface(strSurfaceName, out exists);

            objSurface.BreaklinesDefinition.AddStandardBreaklines(idsBrks, 1.0, 0, 0, 0);
            objSurface.BuildOptions.CrossingBreaklinesElevationOption = Autodesk.Civil.CrossingBreaklinesElevationType.UseAverage;

            SelectionSet objSSetLim = EW_Utility1.buildSSetGradingLim();

            if (objSSetLim.Count == 0)
            {
                MessageBox.Show("GRADING LIMIT not found - OUTER BOUNDARY not added.");
                return;
            }


            ObjectId idLWPline = objSSetLim.GetObjectIds()[0];

            Conv.processBndry(idLWPline);

            ObjectId[] id3dPoly = { Conv.poly_Poly3d(idLWPline, 0, "0") };

            objSurface.BoundariesDefinition.AddBoundaries(new ObjectIdCollection(id3dPoly), 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true);
            objSurface.Rebuild();
            id3dPoly[0].delete();
        }
Пример #2
0
        modSurface(string nameSurface, string descSurface, ObjectIdCollection idsPoly3d, bool boolNewSurface)
        {
            bool       exists     = false;
            TinSurface objSurface = Surf.getTinSurface(nameSurface, out exists);

            if (!exists)
            {
                objSurface.StyleId = Surf_Styles.getSurfaceStyle(nameSurface);
            }

            objSurface.BreaklinesDefinition.AddStandardBreaklines(idsPoly3d, 1, 0, 0, 0);
            objSurface.BuildOptions.CrossingBreaklinesElevationOption = Autodesk.Civil.CrossingBreaklinesElevationType.UseAverage;
            objSurface.Rebuild();
        }
Пример #3
0
        public void AddBoundaryToSurfaceHide()
        {
            Editor ed = acadDoc.Editor;

            ObjectId[] boundaries = { border };

            try
            {
                ts.BoundariesDefinition.AddBoundaries(
                    new ObjectIdCollection(boundaries), 100, Autodesk.Civil.SurfaceBoundaryType.Hide, true);
                ts.Rebuild();
            }

            catch (System.Exception e)
            {
                ed.WriteMessage("Failed to add the boundary: {0}", e.Message);
            }
        }
Пример #4
0
        public static void makeSurfaceBOT()
        {
            string strSurfaceName = "BOT";

            EW_CheckSurfaceStyles.checkSurfaceStyles(strSurfaceName);

            Surf.removeSurface("BOT");
            TinSurface objSurfaceBOT = Surf.addTinSurface("BOT", out exists);

            ObjectId idCivilPntGrp = CgPnt_Group.checkPntGroup("BOT");

            objSurfaceBOT.PointGroupsDefinition.AddPointGroup(idCivilPntGrp);

            SelectionSet objSSet = EW_Utility1.buildSSet13();

            ObjectId[]         idsBrksArray = objSSet.GetObjectIds();
            ObjectIdCollection idsBrks      = new ObjectIdCollection();

            foreach (ObjectId id in idsBrksArray)
            {
                idsBrks.Add(id);
            }

            objSurfaceBOT.BreaklinesDefinition.AddStandardBreaklines(idsBrks, 1.0, 0, 0, 0);

            ObjectId idLWPline = EW_Utility1.buildSSetGradingLim().GetObjectIds()[0];

            if (idLWPline != ObjectId.Null)
            {
                ObjectIdCollection ids = new ObjectIdCollection();
                ids.Add(idLWPline);
                objSurfaceBOT.BoundariesDefinition.AddBoundaries(ids, 1, Autodesk.Civil.SurfaceBoundaryType.Outer, true);
                objSurfaceBOT.Rebuild();
            }
            else
            {
                MessageBox.Show("GRADING LIMIT not found - OUTER BOUNDARY not added.");
            }
        }
Пример #5
0
        RBA()
        {
            Surface surface = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDoc())
                {
                    ObjectIdCollection ids = BaseObjs._civDoc.GetSurfaceIds();
                    if (ids.Count == 0)
                    {
                        return;
                    }
                    foreach (ObjectId id in ids)
                    {
                        try
                        {
                            surface = (Surface)tr.GetObject(id, OpenMode.ForRead);
                            if (surface is TinSurface)
                            {
                                TinSurface tinSurface = (TinSurface)surface;
                                tinSurface.UpgradeOpen();
                                tinSurface.Rebuild();
                                tinSurface.DowngradeOpen();
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " cmdRB.cs: line: 71");
                        }
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRB.cs: line: 79");
            }
        }
Пример #6
0
        makeRemSurface(double dblDepth)
        {
            EW_CheckSurfaceStyles.checkSurfaceStyles("EXIST");

            Point3d pnt3dMove0 = Point3d.Origin;
            Point3d pnt3dMoveX = new Point3d(0, 0, dblDepth * -1);

            Matrix3d mtx3d = Matrix3d.Displacement(pnt3dMoveX - pnt3dMove0);

            TinSurface objSurfaceExist = Surf.getTinSurface("EXIST");
            ObjectId   idSurface       = objSurfaceExist.copy();

            using (var tr = BaseObjs.startTransactionDb()) {
                TinSurface surface = (TinSurface)tr.GetObject(idSurface, OpenMode.ForWrite);
                surface.Name = "EG-ADJ2";

                Layer.manageLayers("EG-ADJ2-SURFACE");
                surface.Layer = "EG-ADJ2" + "-SURFACE";
                surface.TransformBy(mtx3d);
                surface.Rebuild();
            }
        }
Пример #7
0
        RB()
        {
            bool exists             = false;
            ObjectIdCollection ids  = BaseObjs._acadDoc.getBrkLines();
            ObjectIdCollection idsF = BaseObjs._acadDoc.getFeatureLines();

            foreach (ObjectId id in idsF)
            {
                ids.Add(id);
            }

            ObjectId          idSurface = Base_Tools45.C3D.Surf.getSurface("CPNT-ON", out exists);
            Point3dCollection pnts3d    = mySurfaces.getOuterBoundary("CPNT-ON");

            Layer.manageLayers("CPNT-BNDRY");
            ObjectId           idPoly   = pnts3d.addPoly("CPNT-BNDRY");
            ObjectIdCollection idsBndry = new ObjectIdCollection {
                idPoly
            };

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    TinSurface tinSurface = (TinSurface)tr.GetObject(idSurface, OpenMode.ForWrite);
                    tinSurface.deleteBreaklines();
                    tinSurface.BreaklinesDefinition.AddStandardBreaklines(ids, 1.0, 0.0, 0.0, 0.0);
                    tinSurface.BoundariesDefinition.AddBoundaries(idsBndry, 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true);
                    tinSurface.Rebuild();
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRB.cs: line: 41");
            }
        }
Пример #8
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();
            }
        }
Пример #9
0
        public static void Detach()
        {
            Document doc     = Application.DocumentManager.MdiActiveDocument;
            var      ed      = doc.Editor;
            var      civil   = CivilApplication.ActiveDocument;
            var      surfIds = civil.GetSurfaceIds();

            var selRes = ed.SelectImplied();

            if (selRes.Status != PromptStatus.OK)
            {
                return;
            }
            List <ObjectId> idsFlToDetach = selRes.Value.GetObjectIds().ToList();
            List <ObjectId> idsFlDetached = new List <ObjectId>();
            List <ObjectId> idsEditedSurf = new List <ObjectId>();

            using (var t = doc.TransactionManager.StartTransaction())
            {
                bool isEditedSurf = false;
                foreach (ObjectId surfId in surfIds)
                {
                    var             surf    = surfId.GetObject(OpenMode.ForRead) as TinSurface;
                    IAeccTinSurface surfCom = (IAeccTinSurface)surf.AcadObject;

                    for (int i = 0; i < surfCom.Breaklines.Count; i++)
                    {
                        var             brLine            = surfCom.Breaklines.Item(i);
                        var             brLineEnts        = (object[])brLine.BreaklineEntities;
                        List <ObjectId> idBreaklinesToAdd = new List <ObjectId>();
                        bool            isFind            = false;
                        for (int b = 0; b < brLineEnts.Length; b++)
                        {
                            var brLineId = Autodesk.AutoCAD.DatabaseServices.DBObject.FromAcadObject(brLineEnts[b]);
                            idBreaklinesToAdd.Add(brLineId);
                            if (idsFlToDetach.Contains(brLineId))
                            {
                                //surf.BreaklinesDefinition.RemoveAt(i); // не всегда срабатывает!?
                                surfCom.Breaklines.Remove(i);
                                idBreaklinesToAdd.Remove(brLineId);
                                isFind = true;
                                idsFlDetached.Add(brLineId);
                            }
                        }
                        if (isFind)
                        {
                            isEditedSurf = true;
                            if (idBreaklinesToAdd.Any())
                            {
                                AddBreaklinesToSurface(surf, idBreaklinesToAdd);
                            }
                        }
                    }
                    if (isEditedSurf)
                    {
                        isEditedSurf = false;
                        idsEditedSurf.Add(surfId);
                    }
                }

                // Изменение стиля характерной линии
                StyleHelper.Change(idsFlDetached, "Удаленные из поверхности");

                t.Commit();
            }

            // Перестройка поверхностей
            using (var t = doc.TransactionManager.StartTransaction())
            {
                foreach (var idSurf in idsEditedSurf)
                {
                    TinSurface surface = idSurf.GetObject(OpenMode.ForWrite) as TinSurface;
                    surface.Rebuild();
                }
                t.Commit();
            }
        }
Пример #10
0
        public static ObjectId CroppingSurface5(TinSurface surface, Polyline border)
        {
            Document activeDoc   = Tools.GetActiveAcadDocument();
            Database sourceDb    = activeDoc.Database;
            var      points      = border.GetPoints();
            string   surfaceName = "Cropped_" + surface.Name + "<[Next Counter(CP)]>";

            using (Database destDb = new Database(true, false))
            {
                HostApplicationServices.WorkingDatabase = destDb;
                ObjectId newSurfaceId = TinSurface.CreateByCropping(destDb, surfaceName, surface.Id, points);
                HostApplicationServices.WorkingDatabase = sourceDb;

                using (Transaction transDest = Tools.StartTransaction(destDb))
                {
                    TinSurface newSurface = transDest.GetObject(newSurfaceId, OpenMode.ForRead) as TinSurface;

                    /*newSurface = newSurface.Clone() as TinSurface;
                     *
                     * newSurface.SetDatabaseDefaults(sourceDb);
                     * Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = activeDoc;
                     * Tools.AppendEntity(sourceDb, newSurface);*/

                    //newSurface = newSurface.Clone() as TinSurface;
                    transDest.Commit();
                    newSurface = newSurface.Clone() as TinSurface;
                    newSurface.SetDatabaseDefaults(sourceDb);
                    newSurface.SetToStandard(sourceDb);
                    newSurface.StyleId = surface.StyleId;

                    IntPtr ptr = newSurface.UnmanagedObject;
                    var    obj = TinSurface.Create(ptr, false);

                    using (Transaction srcTrans = Tools.StartTransaction(sourceDb))
                    {
                        newSurfaceId = TinSurface.Create(sourceDb, "test_surface");

                        newSurface.SetDatabaseDefaults(sourceDb);
                        newSurface.SetToStandard(sourceDb);
                        newSurface.SetDefaultLayer();
                        newSurface.StyleId = surface.StyleId;

                        //newSurface = srcTrans.GetObject(TinSurface.Create(sourceDb, "test_surface"), OpenMode.ForWrite) as TinSurface;
                        //newSurface.CopyFrom(obj);
                        newSurface.Rebuild();
                        srcTrans.Commit();
                    }
                    using (Transaction srcTrans = Tools.StartTransaction(sourceDb))
                    {
                        newSurface = srcTrans.GetObject(newSurfaceId, OpenMode.ForWrite) as TinSurface;

                        newSurface.UpgradeOpen();

                        newSurface.CopyFrom(obj);
                        //newSurface.Name = "test_surface2";

                        newSurface.SetDatabaseDefaults(sourceDb);
                        newSurface.SetToStandard(sourceDb);
                        newSurface.SetDefaultLayer();

                        newSurface.StyleId = surface.StyleId;
                        newSurface.Rebuild();

                        srcTrans.Commit();
                    }

                    using (Transaction srcTrans = Tools.StartTransaction(sourceDb))
                    {
                        newSurface = srcTrans.GetObject(newSurfaceId, OpenMode.ForWrite) as TinSurface;
                        newSurface.UpgradeOpen();

                        newSurface.SetDatabaseDefaults(sourceDb);
                        newSurface.SetToStandard(sourceDb);
                        newSurface.SetDefaultLayer();

                        srcTrans.Commit();
                        newSurface.Rebuild();
                        //newSurface.RebuildSnapshot();
                        newSurface.CreateSnapshot();
                    }

                    //Tools.AppendEntity(sourceDb, obj as TinSurface);
                }
            }

            return(ObjectId.Null);
        }
Пример #11
0
        TP2()
        {
            Point3d pnt3d1 = UserInput.getPoint("\nPick Corner 1: ", Pub.pnt3dO, out escaped, out ps, osMode: 0);

            if (pnt3d1 == Pub.pnt3dO)
            {
                return;
            }

            Point3d pnt3d2 = UserInput.getPoint("\nPick Baseline direction: ", pnt3d1, out escaped, out ps, osMode: 0);

            if (pnt3d1 == Pub.pnt3dO)
            {
                return;
            }

            Vector2d v2dX = pnt3d2.Convert2d(BaseObjs.xyPlane) - pnt3d1.Convert2d(BaseObjs.xyPlane);
            Vector2d v2dY = v2dX.RotateBy(System.Math.PI / 2);

            Vector3d v3dY = new Vector3d(v2dY.X, v2dY.Y, 0);

            Point3d pnt3dY = pnt3d1 + v3dY;

            Matrix3d m3d = UCsys.addUCS(pnt3d1, pnt3d2, "temp");

            Point3d  pnt3d0 = Db.wcsToUcs(pnt3d1);
            Polyline poly   = jigPolylineArea(pnt3d0);

            UCsys.setUCS2World();

            poly.ObjectId.transformToWcs(BaseObjs._db);

            escaped = UserInput.getUserInputDoubleAsString("\nEnter Elevation: ", out elev, elev);
            if (escaped)
            {
                return;
            }

            escaped = UserInput.getUserInputDoubleAsString("\nEnter Slope: ", out slope, slope);
            if (escaped)
            {
                return;
            }

            double  dblSlope = double.Parse(slope);
            Point3d pnt3dCEN = poly.getCentroid();

            Point3d pnt3dTAR = UserInput.getPoint("\nPick edge of polygon in the Direction of Increasing Slope: ", pnt3dCEN, out escaped, out ps, osMode: 641);

            if (pnt3dTAR == Pub.pnt3dO)
            {
                return;
            }

            ObjectIdCollection idspoly3d = new ObjectIdCollection();

            double   dblDist  = 0.0;
            ObjectId idPoly3d = ObjectId.Null;

            pnt3dCEN = pnt3dCEN.addElevation(double.Parse(elev));

            if (pnt3dTAR != Pub.pnt3dO)
            {
                dblDist = pnt3dCEN.getDistance(pnt3dTAR);
            }
            string nameLayer = string.Format("{0}-BORDER", "BASIN");

            Layer.manageLayers(nameLayer);

            int      numObj = 0;
            bool     exists = false;
            ObjectId idDict = Dict.getNamedDictionary(apps.lnkBrks, out exists);

            if (exists)
            {
                numObj = idDict.getDictEntries().Count;
            }

            string nameSurf = string.Format("{0}{1}", "BASIN", numObj.ToString("00"));

            ObjectId idDictObj = Dict.addSubDict(idDict, nameSurf);

            using (BaseObjs._acadDoc.LockDocument())
            {
                if (pnt3dTAR != Pub.pnt3dO)
                {
                    pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dCEN.Z + dblDist * dblSlope);
                    idPoly3d = Base_Tools45.C3D.DrawBasinBot.build3dPolyBasinBot(poly.ObjectId, pnt3dCEN, pnt3dTAR, dblSlope, nameLayer, apps.lnkBrks);
                }
                else
                {
                    idPoly3d = Conv.poly_Poly3d(poly.ObjectId, double.Parse(elev), nameLayer);
                }
                idspoly3d.Add(idPoly3d);

                TinSurface surf = Surf.addTinSurface(nameSurf, out exists);
                if (exists)
                {
                    Application.ShowAlertDialog(string.Format("Surface Name conflict - surface \"{0}\" already exists.  Exiting...", nameSurf));
                    return;
                }

                surf.BreaklinesDefinition.AddStandardBreaklines(idspoly3d, 1.0, 0.0, 0.0, 0.0);
                surf.Rebuild();
            }

            using (BaseObjs._acadDoc.LockDocument())
            {
                BaseObjs.regen();
            }
        }