Example #1
0
 getSectionViewBandSetStyle(string name)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             SectionViewBandSetStyleCollection styles = BaseObjs._civDoc.Styles.SectionViewBandSetStyles;
             foreach (ObjectId style in styles)
             {
                 SectionViewBandSetStyle svbsStyle = (SectionViewBandSetStyle)tr.GetObject(style, OpenMode.ForRead);
                 if (svbsStyle.Name == name)
                 {
                     return(svbsStyle);
                 }
             }
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} Sect_Style.cs: line: 115", ex.Message));
     }
     return(null);
 }
Example #2
0
        cmdSections(ObjectId idAlign, double dblOffR, double dblOffL)
        {
            ObjectId idSectionStyleEXIST   = default(ObjectId);
            ObjectId idSectionStyleEXIST90 = default(ObjectId);
            ObjectId idSectionStyleCPNT    = default(ObjectId);
            ObjectId idSectionStyleSG      = default(ObjectId);
            ObjectId idSectionStyleOX      = default(ObjectId);
            ObjectId idSectionStyleOXg     = default(ObjectId);
            ObjectId idSectionStyleBOT     = default(ObjectId);
            ObjectId idSectionStyleMID     = default(ObjectId);

            ObjectIdCollection idsSurface = new ObjectIdCollection();

            bool     exists         = false;
            ObjectId idSurfaceEXIST = Surf.getSurface("EXIST", out exists);

            if (!exists)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Surface EXIST is missing - exiting!");
                return;
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST);
                idSectionStyleEXIST = Sect_Style.getSectionStyleId("EXIST");
            }

            ObjectId idSurfaceEXIST90 = Surf.getSurface("EXIST90", out exists);

            if (!exists)
            {
                //  MsgBox "Surface EXIST is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST90);
                idSectionStyleEXIST90 = Sect_Style.getSectionStyleId("EXIST90");
            }

            ObjectId idSurfaceCPNT = Surf.getSurface("CPNT-ON", out exists);

            if (!exists)
            {
                //  MsgBox "Surface CPNT-ON is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceCPNT);
                idSectionStyleCPNT = Sect_Style.getSectionStyleId("CPNT");
            }

            ObjectId idSurfaceSG = Surf.getSurface("SG", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceSG);
                idSectionStyleSG = Sect_Style.getSectionStyleId("SG");
            }

            ObjectId idSurfaceOX = Surf.getSurface("OX", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOX);
                idSectionStyleOX = Sect_Style.getSectionStyleId("OX");
            }

            ObjectId idSurfaceOXg = Surf.getSurface("OXg", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOXg);
                idSectionStyleOXg = Sect_Style.getSectionStyleId("OXg");
            }

            ObjectId idSurfaceBOT = Surf.getSurface("BOT", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceBOT);
                idSectionStyleBOT = Sect_Style.getSectionStyleId("BOT");
            }

            if (idSectionStyleBOT == ObjectId.Null)
            {
                EW_Utility1.copyEWstyles();
            }

            ObjectId idSurfaceMID = Surf.getSurface("MIDGRADE", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceMID);
                idSectionStyleMID = Sect_Style.getSectionStyleId("EXIST90");
            }

            idAlign.removeSampleLineGroups();
            ObjectId idSLG = idAlign.addSampleLineGroupAndSampleLines("EW");

            idSLG.removeSampledSurfaces();

            idSLG.addSurfaceToSample(idsSurface);

            idAlign.addSections(idSLG, dblOffL, dblOffR);

            ObjectId idGroupPlotStyle             = ObjectId.Null;
            GroupPlotStyleCollection grpPltStyles = BaseObjs._civDoc.Styles.GroupPlotStyles;

            if (!grpPltStyles.Contains("EW"))
            {
                EW_Utility1.copyEWstyles();
                idGroupPlotStyle = BaseObjs._civDoc.Styles.GroupPlotStyles["EW"];
            }

            SampleLineStyleCollection sampleLineStyles = BaseObjs._civDoc.Styles.SampleLineStyles;
            ObjectId idSampleLineStyle = sampleLineStyles["Standard"];

            SectionLabelSetStyleCollection sectionLabelSetStyles = BaseObjs._civDoc.Styles.LabelSetStyles.SectionLabelSetStyles;

            double dblWidth  = 0;
            double dblHeight = 0;

            Autodesk.AutoCAD.DatabaseServices.Table objTable = default(Autodesk.AutoCAD.DatabaseServices.Table);

            SelectionSet objSSet = default(SelectionSet);

            objSSet  = EW_Utility1.buildSSetTable();
            objTable = (Autodesk.AutoCAD.DatabaseServices.Table)objSSet.GetObjectIds()[0].getEnt();

            Point3d varPntIns = objTable.Position;

            dblWidth  = objTable.Width;
            dblHeight = objTable.Height;

            Point3d dblPntBase = new Point3d(varPntIns.X + dblWidth + 600, varPntIns.Y - dblHeight, 0);

            SectionViewStyle objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");

            if (objSectionViewStyle == null)
            {
                EW_Utility1.copyEWstyles();
                objSectionViewStyle = objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");
            }

            SectionViewBandSetStyle objSectionViewBandSetStyle = Sect_Style.getSectionViewBandSetStyle("Standard");

            double dblOffX = 0;
            double dblOffY = 0;

            bool boolFirstPass = false;

            boolFirstPass = true;

            dblOffX = 0;
            dblOffY = 0;

            Point3d dblPntIns = Pub.pnt3dO;

            int j = 0;
            ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs();

            using (var tr = BaseObjs.startTransactionDb()) {
                for (int i = 0; i < idsSampleLine.Count; i += 5)
                {
                    SampleLine sl = (SampleLine)tr.GetObject(idsSampleLine[i], OpenMode.ForRead);

                    dblPntIns = new Point3d(dblPntBase.X + i / 5 * dblOffX, dblPntBase.Y, 0);
                    int k = -1;

                    while (j < idsSampleLine.Count)
                    {
                        k = k + 1;

                        ObjectId    idSectionView  = SectionView.Create(string.Format("SV-{0}", j), sl.ObjectId, dblPntIns);
                        SectionView objSectionView = (SectionView)tr.GetObject(idSectionView, OpenMode.ForWrite);
                        if (boolFirstPass)
                        {
                            dblOffX       = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30;
                            boolFirstPass = false;
                        }

                        Extents3d ext3d = (Extents3d)objSectionView.Bounds;

                        dblOffY = ext3d.MaxPoint.Y - ext3d.MinPoint.Y + 30;

                        dblPntIns      = new Point3d(dblPntIns.X, dblPntIns.Y + dblOffY, 0);//increment Y after placing first section in column
                        objSectionView = null;

                        j = j + 1;

                        if (k == 4)
                        {
                            break;
                        }
                    }
                }

                tr.Commit();
            }

            BaseObjs.acadActivate();

            return;
        }
Example #3
0
        drawSections()
        {
            Alignment objAlign = default(Alignment);

            try {
                objAlign = fWall1.ACTIVEALIGN;

                if ((objAlign == null))
                {
                    MessageBox.Show("Select Alignment");
                    return;
                }
            }
            catch (System.Exception) {
                MessageBox.Show("Select Alignment");
                return;
            }
            bool exists = false;

            TinSurface objSurfaceEXIST = Surf.getTinSurface("EXIST", out exists);
            TinSurface objSurfaceCPNT  = Surf.getTinSurface("CPNT-ON", out exists);

            //ObjectId objSectionStyleEXISTId = Sect.getSectionStyleId("EXIST");
            //ObjectId objSectionStyleCPNTId = Sect.getSectionStyleId("CPNT");
            //GroupPlotStyle objGroupPlotStyle = Sect.getGroupPlotStyle("WALL");
            //SampleLineStyle objSampleLineStyle = Sect.getSampleLineStyle("Standard");
            //SectionLabelSetStyle objSampleLabelSetStyle = Sect.getSampleLineLabelStyle("Standard");

            double dblLen = objAlign.Length;

            Sect.removeSampleLineGroups(objAlign.ObjectId);

            string strLayer = string.Format("{0}-SEC", objAlign.Name);

            Layer.manageLayers(strLayer);

            ObjectId idSLG = Sect.addSampleLineGroupAndSampleLines(objAlign.ObjectId, "SLG-1");

            idSLG.removeSampledSurfaces();

            ObjectIdCollection idSurfaces = new ObjectIdCollection();

            idSurfaces.Add(objSurfaceCPNT.ObjectId);
            idSurfaces.Add(objSurfaceEXIST.ObjectId);

            idSLG.addSurfaceToSample(idSurfaces);

            Sect.addSections(objAlign.ObjectId, idSLG, 20.0, 20.0);

            SampleLine objSampleLine = default(SampleLine);

            Autodesk.Civil.DatabaseServices.Section objSection = default(Autodesk.Civil.DatabaseServices.Section);

            ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs();

            using (var tr = BaseObjs.startTransactionDb()) {
                foreach (ObjectId idSampleLine in idsSampleLine)
                {
                    objSampleLine = (SampleLine)tr.GetObject(idSampleLine, OpenMode.ForRead);
                    foreach (ObjectId idSection in objSampleLine.GetSectionIds())
                    {
                        objSection       = (Section)tr.GetObject(idSection, OpenMode.ForWrite);
                        objSection.Layer = strLayer;
                    }
                }
                tr.Commit();
            }

            Autodesk.Civil.DatabaseServices.Styles.SectionViewStyle objSectionViewStyle = default(Autodesk.Civil.DatabaseServices.Styles.SectionViewStyle);

            try {
                objSectionViewStyle = Sect_Style.getSectionViewStyle("WALL");
            }
            catch (System.Exception) {
                objSectionViewStyle = Sect_Style.getSectionViewStyle("Standard");
            }

            SectionViewBandSetStyle objSectionViewBandStyleSet = Sect_Style.getSectionViewBandSetStyle("Standard");

            double dblOffX = 0;
            double dblOffY = 0;

            bool boolFirstPass = true;

            //Dim objStationRange As New StationRange
            //With objStationRange
            //    .UseSampleIncrements = True
            //    .SampleAtHighLowPoints = False
            //    .SampleAtHorizontalGeometryPoints = False
            //    .SampleAtSuperelevationCriticalStations = False
            //    .SampleAtRangeEnd = True
            //    .SampleAtRangeStart = True
            //    .StartRangeAtAlignmentStart = True
            //    .EndRangeAtAlignmentEnd = True
            //    .StartRange = 0.0
            //    .EndRange = dblLen - 1
            //    .IncrementTangent = 50.0
            //    .SwathWidthLeft = 20.0
            //    .SwathWidthRight = 20.0
            //    .SampleLineDefaultDirection = DirectionFromType.DirectionFromBaseAlignment
            //End With

            //objStationRange.SampleLineStyle = objSampleLineStyle

            //objSLG.SampleLines.AddByStationRange("SL-1", SampleLineDuplicateActionType.SampleLineDuplicateActionOverwrite, objStationRange)

            PromptStatus ps        = default(PromptStatus);
            Point3d      pnt3dBase = default(Point3d);

            try {
                BaseObjs.acadActivate();
                pnt3dBase = UserInput.getPoint("Select Insertion Point for Sections", out ps, osMode: 0);
            }
            catch (System.Exception) {
                return;
            }

            SectionView objSectionView = null;
            Point3d     pnt3dIns       = default(Point3d);

            using (var tr1 = BaseObjs.startTransactionDb()) {
                int j = 0;
                for (int i = 0; i < idsSampleLine.Count; i += 5)
                {
                    objSampleLine = (SampleLine)tr1.GetObject(idsSampleLine[i], OpenMode.ForRead);

                    //dblPntIns(0) = pnt3dBase.X + i / 5 * dblOffX

                    int k = -1;

                    while (j < idsSampleLine.Count)
                    {
                        k++;

                        pnt3dIns = new Point3d(pnt3dBase.X + i / 5 * dblOffX, pnt3dBase.Y + k * dblOffY, 0.0);

                        try {
                            ObjectId idSectionView = SectionView.Create("SV" + Convert.ToString(j), idsSampleLine[i], pnt3dIns);
                            objSectionView             = (SectionView)tr1.GetObject(idSectionView, OpenMode.ForWrite);
                            objSectionView.OffsetLeft  = 20.0;
                            objSectionView.OffsetRight = 20.0;
                            objSectionView.StyleId     = objSectionViewStyle.ObjectId;
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception) {
                        }

                        if (boolFirstPass)
                        {
                            dblOffX       = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30;
                            dblOffY       = (objSectionView.ElevationMax - objSectionView.ElevationMin) + 20;
                            boolFirstPass = false;
                        }

                        j++;

                        if (k == 4)
                        {
                            break;
                        }
                    }
                }

                tr1.Commit();
            }
        }