Example #1
0
        copySectionViewStyle()
        {
            Document acDocTar = BaseObjs._acadDoc;                                                              // target - Active Document
            Database dbTar    = acDocTar.Database;                                                              // target database

            Document acDocSrc = BaseObjs.openDwg("R:\\TSet\\Template\\CIVIL3D2010\\EW.dwt");                    // source - Active Document

            Application.DocumentManager.MdiActiveDocument = acDocSrc;
            CivilDocument civDocSrc = BaseObjs._civDoc;

            SectionViewStyleCollection objSectionViewStyles = civDocSrc.Styles.SectionViewStyles;               //soubce Section View Styles

            using (Transaction tr = BaseObjs.startTransactionDb()) {
                foreach (ObjectId idStyle in objSectionViewStyles)
                {
                    Styles.SectionViewStyle objSectionViewStyle = (Styles.SectionViewStyle)tr.GetObject(idStyle, OpenMode.ForRead);

                    if (objSectionViewStyle.Name != "Standard")
                    {
                        objSectionViewStyle.ExportTo(dbTar, Autodesk.Civil.StyleConflictResolverType.Override);                         //export from source to target db
                    }
                }
                tr.Commit();
            }

            Application.DocumentManager.MdiActiveDocument = acDocTar;
            acDocSrc.CloseAndDiscard();
        }
Example #2
0
 getSectionViewStyle(string name)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             SectionViewStyleCollection styles = BaseObjs._civDoc.Styles.SectionViewStyles;
             foreach (ObjectId style in styles)
             {
                 SectionViewStyle svStyle = (SectionViewStyle)tr.GetObject(style, OpenMode.ForRead);
                 if (svStyle.Name == name)
                 {
                     return(svStyle);
                 }
             }
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} Sect_Style.cs: line: 135", ex.Message));
     }
     return(null);
 }
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();
            }
        }
Example #4
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 #5
0
        checkSectionViewStyle()
        {
            ObjectId idSectionViewStyle = BaseObjs._civDoc.Styles.SectionViewStyles.Add("EW");

            using (var tr = BaseObjs.startTransactionDb()){
                s.SectionViewStyle svs = (s.SectionViewStyle)tr.GetObject(idSectionViewStyle, OpenMode.ForWrite);

                //----------------------------------Center Axis-----------------------------------
                DisplayStyle ds = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxis);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxisAnnotationMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxisTicksMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxisAnnotationMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxisTicksMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.BottomAxisTitle);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                //----------------------------------Center Axis-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxis);
                ds.Color   = clr.red;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxisAnnotationMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxisTicksMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxisAnnotationMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxisTicksMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.CenterAxisTitle);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                //----------------------------------Graph Style-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GraphTitle);
                ds.Color   = clr.cyn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                //----------------------------------Grid Style-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GridHorizontalMajor);
                ds.Color   = clr.c8;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GridVerticalMajor);
                ds.Color   = clr.c8;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GridHorizontalMinor);
                ds.Color   = clr.c9;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GridVerticalMinor);
                ds.Color   = clr.c9;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                //----------------------------------Left Axis-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxis);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxisAnnotationMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxisTicksMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxisAnnotationMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxisTicksMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.LeftAxisTitle);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;
                //----------------------------------Right Axis-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxis);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxisAnnotationMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxisTicksMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxisAnnotationMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxisTicksMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.RightAxisTitle);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                //----------------------------------Top Axis-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxis);
                ds.Color   = clr.red;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxisAnnotationMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxisTicksMajor);
                ds.Color   = clr.grn;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxisAnnotationMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxisTicksMinor);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.TopAxisTitle);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = false;

                //----------------------------------Sample Line-----------------------------------

                ds         = svs.GetDisplayStylePlan(SectionViewDisplayStyleType.GridAtSampleLineStations);
                ds.Color   = clr.yel;
                ds.Layer   = "SECTIONVIEW";
                ds.Visible = true;

                tr.Commit();
            }
        }