Пример #1
0
        checkAreaLimits(SelectionSet objSSetAreas)
        {
            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();

            if (objSSet.Count == 0)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("GRADING LIMIT missing - exiting..........");
                return;
            }
            ObjectId idGradingLim = objSSet.GetObjectIds()[0];

            objSSet = EW_Utility1.buildSSetBLDG_LIM();
            if (objSSet.Count == 0)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("BUILDING LIMIT missing - exiting.......");
                return;
            }

            if (checkAreaLimit(objSSetAreas, idGradingLim))
            {
                return;
            }

            List <Point3d> varPnts3dBndry0z = getGradingLimitCoords();

            limitIsOutside(objSSetAreas, varPnts3dBndry0z);
        }
Пример #2
0
        public static string getBldgLayer(ObjectId idPolyBLDGLIM)
        {
            List <Point3d> pnts3dBldgLim    = idPolyBLDGLIM.getCoordinates3dList();
            SelectionSet   objSSetFLOORSLAB = EW_Utility1.buildSSetFLOOR_SLAB();

            ObjectId[] ids = objSSetFLOORSLAB.GetObjectIds();

            string strLayer = "";

            for (int i = 0; i < ids.Length; i++)
            {
                Polyline          poly         = (Polyline)ids[i].getEnt();
                Point3dCollection pnts3dPline  = poly.getCoordinates3d();
                Point3d           pnt3dControl = Geom.getCentroid(poly);

                if (Geom.isInside(pnt3dControl, pnts3dBldgLim, false))
                {
                    strLayer = poly.Layer;
                    TypedValue[] tvs = new TypedValue[2] {
                        new TypedValue(1001, "FLOORSLAB"),
                        new TypedValue(1005, poly.Handle)
                    };

                    idPolyBLDGLIM.setXData(tvs, "FLOORSLAB");
                    break;
                }
            }

            return(strLayer);            //as is will return last bldg area inside BLDG LIM if more than one FLOOR SLAB
        }
Пример #3
0
        public static void reTest()
        {
            try {
                double dblDepth = EW_Utility1.getRemoveAndReplace();

                object[] dblGridData = new object[3];

                ObjectId     idDictBOT = Dict.getNamedDictionary("BOT", out exists);
                ResultBuffer rb        = idDictBOT.getXData("BOT");
                if (rb == null)
                {
                    return;
                }
                TypedValue[] tvs = rb.AsArray();

                dblGridData[0] = tvs[1].Value.ToString();
                dblGridData[1] = tvs[2].Value.ToString();
                dblGridData[2] = tvs[3].Value.ToString();

                SelectionSet objSSet = EW_Utility1.buildSSet13();
                objSSet.eraseSelectedItems();

                testBotElev(dblGridData, true);
            }
            catch {
                MessageBox.Show("  - reTest");
            }
        }
Пример #4
0
        updateSpreadsheet(ref double dblVolFill, ref double dblVolCut)
        {
            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = strPath + "\\" + strFN;

            SelectionSet objSSet = EW_Utility1.buildSSet22();

            if ((dblVolFill == 0))
            {
                bool     exists;
                ObjectId idSurfaceCUT  = Surf.getSurface("VOL_EXIST_BOT", out exists);
                ObjectId idSurfaceFILL = Surf.getSurface("VOL_BOT_SG", out exists);

                TinVolumeSurface objSurfaceFILL = (TinVolumeSurface)idSurfaceFILL.getEnt();
                TinVolumeSurface objSurfaceCUT  = (TinVolumeSurface)idSurfaceCUT.getEnt();

                dblVolCut  = objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27;
                dblVolCut  = dblVolCut + objSurfaceCUT.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = dblVolFill + objSurfaceCUT.GetVolumeProperties().UnadjustedFillVolume / 27;
            }

            if (spreadSheetExists(strFullPath, dblVolFill, dblVolCut))
            {
                Excel_ext excl = new Excel_ext(true);
                excl.OpenFile(strFullPath, "");
                excl.FindExcelWorksheet("SUMMARY");

                Excel._Worksheet objWS = excl.excelWrkSht;

                objWS.Range["SUMMARY!volCUT"].Value  = dblVolCut;
                objWS.Range["SUMMARY!volFILL"].Value = dblVolFill;

                //objWS.Range["SUMMARY!AREA_BLDG"].Value = 0;

                excl.CloseFile(true, strFullPath, false);
                excl.excelAPP.Quit();
            }
            else
            {
                MessageBox.Show("Error copying EW spreadsheet");
            }

            objSSet = EW_Utility1.buildSSet8();
            if (objSSet != null && objSSet.Count > 0)
            {
                ObjectId[] ids = objSSet.GetObjectIds();
                for (int i = 0; i < ids.Length; i++)
                {
                    ids[i].delete();
                }
            }

            setupSpreadSheetMS(dblVolFill, dblVolCut);
        }
Пример #5
0
        makeVolSurface(string strNameBASE, string strNameCOMP, bool boolShowMessage)
        {
            string        nameSurface  = string.Format("VOL_{0}_{1}", strNameBASE, strNameCOMP);
            List <string> nameSurfaces = Surf.getSurfaces();

            for (int i = 0; i < nameSurfaces.Count; i++)
            {
                if (nameSurfaces[i] == nameSurface)
                {
                    Surf.removeSurface(nameSurfaces[i]);
                }
            }

            TinSurface objSurfaceBASE = Surf.getTinSurface(strNameBASE);
            TinSurface objSurfaceCOMP = Surf.getTinSurface(strNameCOMP);

            int lngVolCut  = 0;
            int lngVolFill = 0;

            ObjectId idSurfFill = TinVolumeSurface.Create(nameSurface, objSurfaceBASE.ObjectId, objSurfaceCOMP.ObjectId);

            SelectionSet objSSetLim = EW_Utility1.buildSSetGradingLim();

            ObjectId[]       ids            = objSSetLim.GetObjectIds();
            TinVolumeSurface objSurfaceFILL = null;

            if (ids != null && ids.Length > 0)
            {
                ObjectId idPoly = ids[0];
                idPoly.checkIfClosed();

                ObjectId   idPoly3d = Conv.poly_Poly3d(idPoly, 0, "0");
                ObjectId[] idBndrys = { idPoly3d };
                objSurfaceFILL = (TinVolumeSurface)idSurfFill.getEnt();
                objSurfaceFILL.BoundariesDefinition.AddBoundaries(new ObjectIdCollection(idBndrys), 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true);
                objSurfaceFILL.Rebuild();
                idPoly3d.delete();
            }
            else
            {
                MessageBox.Show("GRADING LIMIT not found - OUTER BOUNDARY not added.");
            }

            lngVolCut  = (int)objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27;
            lngVolFill = (int)objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27;

            if (boolShowMessage == true)
            {
                string mess = string.Format("Cut: {0} CY     Fill: {1} CY", lngVolCut, lngVolFill);
                MessageBox.Show(mess);
            }

            EW_Main.viewResults("VOL", false);
        }
Пример #6
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();
        }
Пример #7
0
        getGradingLimitCoords()
        {
            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();

            if (objSSet.Count == 0)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("GRADING LIMIT missing - exiting..........");
                return(null);
            }
            ObjectId[]     ids           = objSSet.GetObjectIds();
            List <Point3d> pnts3dBndry0z = ids[0].getCoordinates3dList();

            for (int i = 0; i < pnts3dBndry0z.Count; i++)
            {
                pnts3dBndry0z[i] = new Point3d(pnts3dBndry0z[i].X, pnts3dBndry0z[i].Y, 0.0);
            }

            return(pnts3dBndry0z);
        }
Пример #8
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.");
            }
        }
Пример #9
0
        getLimits(int intInterval)
        {
            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();

            if (objSSet.Count == 0)
            {
                Application.ShowAlertDialog("Grading Limit not found - should be on layer GRADING LIMIT - exiting....");
                return(null);
            }
            else if (objSSet.Count > 1)
            {
                Application.ShowAlertDialog("More than one Project Boundary found - exiting....");
                return(null);
            }

            ObjectId[] ids = objSSet.GetObjectIds();

            Polyline objPlineBndry = (Polyline)ids[0].getEnt();

            Extents3d ext3d    = (Extents3d)objPlineBndry.Bounds;
            Point3d   pnt3dMin = new Point3d(ext3d.MinPoint.X - 100, ext3d.MinPoint.Y - 100, 0.0);
            Point3d   pnt3dMax = new Point3d(ext3d.MaxPoint.X + 100, ext3d.MaxPoint.Y + 100, 0.0);

            double dblDeltaX = pnt3dMax.X - pnt3dMin.X;
            double dblDeltaY = pnt3dMax.Y - pnt3dMin.Y;


            int iMax = (int)System.Math.Truncate(dblDeltaX / intInterval);
            int jMax = (int)System.Math.Truncate(dblDeltaY / intInterval);

            object[] varLimits = new object[4];
            varLimits[0] = pnt3dMin.X;
            varLimits[1] = pnt3dMin.Y;
            varLimits[2] = iMax;
            varLimits[3] = jMax;

            return(varLimits);
        }
Пример #10
0
        public static void makeSurfaceOXg()
        {
            Layer.manageLayers("OXg-BRKLINE");
            Layer.manageLayers("OXg-BRKLINE-AREA");
            Layer.manageLayers("OXg-SURFACE");

            SelectionSet ss = EW_Utility1.buildSSetOXg();

            ObjectId[] ids = ss.GetObjectIds();

            for (int i = 0; i < ids.Length; i++)
            {
                ObjectId idOXg    = ids[i];
                string   strLayer = idOXg.getLayer();

                ObjectId idLWPlineX = idOXg.offset(-0.05);

                if (idLWPlineX == ObjectId.Null)
                {
                    idOXg.changeProp(LineWeight.LineWeight200, Misc.getColorByBlock(206));
                }
                else
                {
                    idLWPlineX.changeProp(LineWeight.LineWeight100, clr.mag);

                    if (!offsetSegments("SG", "OXg", idLWPlineX, strLayer))
                    {
                        return;
                    }
                }
            }

            if (ss.Count > 0)
            {
                viewResults("OXg", true);
            }
        }
Пример #11
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;
        }
Пример #12
0
        makeBaseline()
        {
            Layer.manageLayers("GRADING LIMIT");
            Layer.manageLayers("SECTIONS");

            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();
            Entity       ent     = objSSet.GetObjectIds()[0].getEnt();
            ObjectId     idLim   = ent.ObjectId;

            double    dblStationBase = 0;
            bool      boolUseBase;
            Alignment objAlignBASE = null;
            Alignment objAlign     = Align.getAlignment("BASE");

            if (objAlign != null)
            {
                DialogResult varResponse = MessageBox.Show("Use existing BASE alignment for sections?", "", MessageBoxButtons.YesNo);

                if (varResponse == DialogResult.Yes)
                {
                    objAlignBASE   = objAlign;
                    dblStationBase = objAlignBASE.StartingStation;

                    objAlign    = null;
                    boolUseBase = true;
                }
                else
                {
                    boolUseBase   = false;
                    objAlign.Name = "BASE_old";
                }
            }
            else
            {
                boolUseBase = false;
            }
            List <Point3d> varPntInts = new List <Point3d>();
            ObjectId       idLWPline = ObjectId.Null, idLine = ObjectId.Null;
            double         dblAng = 0;
            bool           exists;
            Point3d        pnt3dCEN = Pub.pnt3dO, pnt3dTAR = Pub.pnt3dO, dPntBeg = Pub.pnt3dO, dPntEnd = Pub.pnt3dO;

            if (!boolUseBase)
            {
                ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);

                if (!exists)
                {
                    Application.ShowAlertDialog("GRADEDOCK Dictionary missing. Create alignment BASE and try again.");
                    return;
                }
                else
                {
                    ResultBuffer rb  = Dict.getXRec(idDictGRADEDOCK, "CENTROID");
                    TypedValue[] tvs = rb.AsArray();

                    pnt3dCEN = new Point3d(double.Parse(tvs[0].Value.ToString()),
                                           double.Parse(tvs[1].Value.ToString()),
                                           double.Parse(tvs[2].Value.ToString()));

                    rb  = Dict.getXRec(idDictGRADEDOCK, "TARGET");
                    tvs = rb.AsArray();

                    pnt3dTAR = new Point3d(double.Parse(tvs[0].Value.ToString()),
                                           double.Parse(tvs[1].Value.ToString()),
                                           double.Parse(tvs[2].Value.ToString()));
                }

                idLine = Draw.addLine(pnt3dCEN, pnt3dTAR);

                varPntInts = idLine.intersectWith(idLim, extend.source);
                idLine.delete();

                dPntBeg = varPntInts[0];
                dPntEnd = varPntInts[1];

                dblAng = dPntBeg.getDirection(dPntEnd);

                if (dblAng > pi / 2 & dblAng <= 3 * pi / 2)
                {
                    varPntInts.Reverse();
                    dPntBeg = varPntInts[0];
                    dPntEnd = varPntInts[1];

                    dblAng = Measure.getAzRadians(dPntBeg, dPntEnd);
                }

                idLWPline = Draw.addPoly(varPntInts);

                dblStationBase = 0;
            }

            Point3d pnt3dB = dPntBeg.traverse(dblAng, 10);
            Point3d pnt3dE = dPntEnd.traverse(dblAng, 10);
            Point3d pnt3dM = pnt3dB.getMidPoint3d(pnt3dE);

            if ((objAlignBASE == null))
            {
                objAlignBASE = Align.addAlignmentFromPoly("BASE", "SECTIONS", idLWPline, "Standard", "Standard", true, true);
            }

            AlignmentEntityCollection ents = objAlignBASE.Entities;

            AlignmentEntity objAlignEnt = ents[0];

            if (objAlignEnt.EntityType == AlignmentEntityType.Line)
            {
                AlignmentLine objAlignEntTan = (AlignmentLine)objAlignEnt;
                Point2d       pnt2dBeg       = objAlignEntTan.StartPoint;
                Point2d       pnt2dEnd       = objAlignEntTan.EndPoint;

                dblAng = pnt2dBeg.getDirection(pnt2dEnd);
            }

            int    j = -1;
            double easting = 0, northing = 0;
            double dblOffR = 0, dblOffL = 0;

            while (dblStationBase < objAlignBASE.Length)
            {
                j = j + 1;
                dblStationBase = dblStationBase + j * 50;
                objAlignBASE.PointLocation(dblStationBase, 0.0, ref easting, ref northing);
                Point3d pnt3dX      = new Point3d(easting, northing, 0);
                Point3d varPntPolar = pnt3dX.traverse(dblAng + pi / 2, 100.0);
                idLine     = Draw.addLine(pnt3dX, varPntPolar);
                varPntInts = idLine.intersectWith(idLim, extend.source);
                idLine.delete();

                StaOff sOff = new StaOff();
                sOff.Sta = dblStationBase;
                double dblStation = 0, dblOffset = 0;

                for (int k = 0; k < varPntInts.Count; k++)
                {
                    objAlignBASE.StationOffset(varPntInts[k].X, varPntInts[k].Y, ref dblStation, ref dblOffset);

                    if (dblOffset >= 0)
                    {
                        sOff.R = dblOffset;
                    }
                    else
                    {
                        sOff.L = System.Math.Abs(dblOffset);
                    }

                    if (sOff.R > dblOffR)
                    {
                        dblOffR = sOff.R;
                    }

                    if (sOff.L > dblOffL)
                    {
                        dblOffL = sOff.L;
                    }

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

            double dblRem = dblOffL % 10;

            if (dblRem < 5)
            {
                dblOffL = System.Math.Round(dblOffL / 10, 0) * 10 + 10;
            }
            else
            {
                dblOffL = System.Math.Round(dblOffL / 10, 0) * 10;
            }

            dblRem = dblOffR % 10;

            if (dblRem < 5)
            {
                dblOffR = System.Math.Round(dblOffR / 10, 0) * 10 + 10;
            }
            else
            {
                dblOffR = System.Math.Round(dblOffR / 10, 0) * 10;
            }

            EW_CmdSections.cmdSections(objAlignBASE.ObjectId, dblOffR, dblOffL);
        }
Пример #13
0
        public static bool offsetSegments(string strSurfaceName, string strSurfaceNameX, ObjectId idLWPlineX, string varLayerName = "")
        {
            double dblZOff = 0;

            int intCase1 = 0, intCase2_1 = 0, intCase2_2 = 0, intCase2_3 = 0, intCase2_4 = 0, intCase2_5 = 0, intCase2_6 = 0, intCase2_7 = 0;
            int intCase2_8 = 0, intCase5_1 = 0, intCase5_2 = 0, intCase5_3 = 0, intCase5_4 = 0, intCase5_5 = 0, intCase8_5 = 0, intCase11 = 0;

            TinSurface objSurfaceSG = null;

            if (strSurfaceName == "SG")
            {
                objSurfaceSG = Surf.getTinSurface("SG", out exists);

                if ((objSurfaceSG == null))
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Surface SG missing - exiting routine");
                    return(false);
                }
            }

            ObjectId id3dBrkP = ObjectId.Null, idTextB = ObjectId.Null, idTextE = ObjectId.Null;
            string   strLayerName = varLayerName;
            ObjectId id3dBndry    = EW_Build3dPoly.buildArea3dLimit(idLWPlineX, strSurfaceName, strSurfaceNameX, strLayerName);         //returns 3D poly with surface elevations, endPnt = begPnt

            if (id3dBndry == ObjectId.Null)
            {
                return(false);
            }

            string strHandle = idLWPlineX.getHandle().ToString();
            string strLayer  = idLWPlineX.getLayer();

            if (varLayerName == "")
            {
                dblZOff = EW_Utility1.getDepth(strLayer, strSurfaceNameX);                  //get depth for area
            }
            else
            {
                if (!varLayerName.Contains("_OX-AREA-"))
                {
                    dblZOff = EW_Utility1.getDepth(varLayerName, strSurfaceNameX);
                }
                else
                {
                    dblZOff = double.Parse(varLayerName.Substring(10));
                }
            }

            Point3d pnt3d0 = new Point3d(0, 0, 0);
            Point3d pnt3dX = new Point3d(0, 0, -dblZOff);

            id3dBndry.moveObj(pnt3d0, pnt3dX);

            if (idLWPlineX == ObjectId.Null)
            {
                MessageBox.Show("idLWPlineX is null");
            }

            List <Point3d> varPnts3dBndry0z = idLWPlineX.getCoordinates3dList();

            idLWPlineX.delete();

            List <Point3d> varPnts3dBndry0zForInt = varPnts3dBndry0z;

            varPnts3dBndry0zForInt.RemoveAt(varPnts3dBndry0z.Count - 1);                //remove endPnt ==>> endPnt <> begPnt

            if (strSurfaceName == "CPNT-ON")
            {
                strLayerName = "CPNT-BRKLINE";
            }
            else
            {
                strLayerName = string.Format("{0}-BRKLINE", strSurfaceName);
            }

            ObjectIdCollection ids = null;

            if (pub.boolDebug)
            {
                escape = Select.getSelSetFromUser(out ids);
            }
            else
            {
                ss = EW_Utility1.buildSSetCPNT_ON_SEGMENTS(strLayerName, varPnts3dBndry0z);                  //select triangle segments (3dPolylines) by polygon crossing
            }

            if (ss == null)
            {
                return(false);
            }

            ObjectId[] idsSegments = ss.GetObjectIds();

            TypedValue[] tvs = new TypedValue[3] {
                new TypedValue(1001, "makeBOT"),
                new TypedValue(1000, varLayerName),
                new TypedValue(1000, "BRKLINES")
            };

            for (int j = 0; j < idsSegments.Length; j++)
            {
                strLayer = string.Format("{0}-BRKLINE", strSurfaceNameX);
                ObjectId id    = idsSegments[j];
                ObjectId idBrk = ObjectId.Null;
                Entity   ent   = id.getEnt();

                if (ent.GetType() == typeof(PolylineVertex3d))
                {
                    idBrk = id.getOwnerOfVertex2d3d();
                }
                else if (ent.GetType() == typeof(Polyline3d))
                {
                    idBrk = id;
                }

                //ent = idBrk.getEnt();
                //MessageBox.Show(ent.GetType().ToString());

                ObjectId id3dBrkX = idBrk.copy(strLayer);

                //ent = id3dBrkX.getEnt();
                //MessageBox.Show(ent.GetType().ToString());


                id3dBrkX.moveObj(pnt3d0, pnt3dX);                  //move copy of triangle edge based on vertical offset
                id3dBrkX.changeProp(clr.byl, strLayer);

                //ent = id3dBrkX.getEnt();
                //MessageBox.Show(ent.GetType().ToString());

                List <Point3d> varPnts3d = id3dBrkX.getCoordinates3dList();

                Point3d dblPntBeg = varPnts3d[0];
                Point3d dblPntEnd = varPnts3d[1];                   //end point of triangle edge (3dPoly segment)
                if (pub.boolDebug)
                {
                    idTextB = Txt.addText("B", dblPntBeg, 0, AttachmentPoint.BottomLeft);
                    idTextB.changeProp(color, "DEBUG-0", LineWeight.LineWeight020);
                }

                if (pub.boolDebug)
                {
                    idTextE = Txt.addText("E", dblPntBeg, 0, AttachmentPoint.BottomLeft);
                    idTextE.changeProp(color, "DEBUG-0", LineWeight.LineWeight020);
                }

                //------------------------------------------------------------------test for intersection
                List <Point3d> dblPntInts = Geom.getPntInts(dblPntBeg, dblPntEnd, varPnts3dBndry0zForInt, false, extend.none);
                //------------------------------------------------------------------test for intersection
                bool boolAddEnt   = false;
                bool boolBegOnSeg = false;
                bool boolEndOnSeg = false;
                bool boolBegIn    = false;
                bool boolEndIn    = false;

                int intUBnd = 0;
                switch ((int)(dblPntInts[0].X))
                {
                case -1:

                    intUBnd = -1;

                    boolBegOnSeg = (dblPntBeg.isOn2dSegment(varPnts3dBndry0zForInt) == -1) ? false : true;
                    boolEndOnSeg = (dblPntEnd.isOn2dSegment(varPnts3dBndry0zForInt) == -1) ? false : true;

                    break;

                case -9:

                    intUBnd      = -9;
                    boolBegOnSeg = true;
                    boolEndOnSeg = true;

                    break;

                default:

                    intUBnd = dblPntInts.Count;

                    boolBegOnSeg = (dblPntBeg.isOn2dSegment(varPnts3dBndry0zForInt) == -1) ? false : true;
                    boolEndOnSeg = (dblPntEnd.isOn2dSegment(varPnts3dBndry0zForInt) == -1) ? false : true;

                    break;
                }

                if (boolBegOnSeg == false)
                {
                    boolBegIn = dblPntBeg.isInside(varPnts3dBndry0zForInt);
                }
                else
                {
                    boolBegIn = true;
                }

                if (boolEndOnSeg == false)
                {
                    boolEndIn = dblPntEnd.isInside(varPnts3dBndry0zForInt);
                }
                else
                {
                    boolEndIn = true;
                }

                switch (intUBnd)
                {
                case -1:
                    //Case -1

                    if (boolBegOnSeg & !boolEndIn)
                    {
                        boolAddEnt = false;
                    }
                    else if (boolEndOnSeg & !boolBegIn)
                    {
                        boolAddEnt = false;
                    }
                    else
                    {
                        boolAddEnt = true;
                        intCase1   = intCase1 + 1;
                    }

                    break;

                case 1:                         //one intersection - one point inside and one outside

                    //Case 2-1
                    if (boolBegOnSeg == true & boolEndOnSeg == true)
                    {
                        //both ends on the line
                        //test midPoint to see if segment is inside or outside
                        Point3d pnt3dMid = dblPntBeg.getMidPoint3d(dblPntEnd);

                        //boolAddEnt = (pnt3dMid.isOn2dSegment(varPnts3dBndry0zForInt) == -1) ? true : false;
                        boolAddEnt = pnt3dMid.isInside(varPnts3dBndry0zForInt);

                        if (boolAddEnt)
                        {
                            intCase5_1 = intCase2_1 + 1;
                        }
                        //Case 2-2
                    }
                    else if (boolBegOnSeg == true & boolEndIn == true)
                    {
                        boolAddEnt = true;
                        intCase2_2 = intCase2_2 + 1;
                        //Case 2-3 ???????????????????????????????????
                    }
                    else if (boolBegOnSeg == true & boolEndIn == false)
                    {
                        if (dblPntInts[0].isOn2dSegment(varPnts3dBndry0zForInt) != -1)
                        {
                            dblPntEnd = dblPntInts[0];
                            double elev = EW_Utility2.getElev(dblPntEnd, id3dBndry);
                            if (elev == 0 && strSurfaceName == "SG")
                            {
                                elev = objSurfaceSG.FindElevationAtXY(dblPntEnd.X, dblPntEnd.Y);
                            }
                            dblPntEnd = dblPntEnd.addElevation(elev);

                            boolAddEnt = true;
                        }
                        else
                        {
                            boolAddEnt = false;
                            intCase2_3 = intCase2_3 + 1;
                        }
                        //Case 2-4
                    }
                    else if (boolEndOnSeg == true & boolBegIn == true)
                    {
                        boolAddEnt = true;
                        intCase2_4 = intCase2_4 + 1;
                        //Case 2-5
                    }
                    else if (boolEndOnSeg == true & boolBegIn == false)
                    {
                        if (dblPntInts[0].isOn2dSegment(varPnts3dBndry0zForInt) != -1)
                        {
                            dblPntBeg = dblPntInts[0];
                            double elev = EW_Utility2.getElev(dblPntBeg, id3dBndry);
                            if (elev == 0 && strSurfaceName == "SG")
                            {
                                elev = objSurfaceSG.FindElevationAtXY(dblPntBeg.X, dblPntBeg.Y);
                            }
                            dblPntBeg  = dblPntBeg.addElevation(elev);
                            boolAddEnt = true;
                        }
                        else
                        {
                            boolAddEnt = false;
                            intCase2_5 = intCase2_5 + 1;
                        }
                        //Case 2-6
                    }
                    else if (boolBegIn == true & boolEndIn == false)
                    {
                        dblPntEnd = dblPntInts[0];
                        double elev = EW_Utility2.getElev(dblPntEnd, id3dBndry);
                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntEnd.X, dblPntEnd.Y);
                        }
                        dblPntEnd = dblPntEnd.addElevation(elev);

                        boolAddEnt = true;
                        intCase2_6 = intCase2_6 + 1;
                        //Case 2-7
                    }
                    else if (boolBegIn == false & boolEndIn == true)
                    {
                        dblPntBeg = dblPntInts[0];
                        double elev = EW_Utility2.getElev(dblPntBeg, id3dBndry);
                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntBeg.X, dblPntBeg.Y);
                        }
                        dblPntBeg = dblPntBeg.addElevation(elev);

                        boolAddEnt = true;
                        intCase2_7 = intCase2_7 + 1;
                        //Case2-8
                    }
                    else if (boolBegIn == true & boolEndIn == true)
                    {
                        boolAddEnt = true;
                        intCase2_8 = intCase2_8 + 1;
                    }

                    break;

                case 2:

                    //Case 5-1
                    if (boolBegOnSeg == true & boolEndOnSeg == true)
                    {
                        //both ends on the line
                        //test miPoint3d to see if segment is inside or outside
                        Point3d pnt3dMid = dblPntBeg.getMidPoint3d(dblPntEnd);
                        boolAddEnt = pnt3dMid.isInside(varPnts3dBndry0zForInt);

                        if (boolAddEnt)
                        {
                            intCase5_1 = intCase5_1 + 1;
                        }
                        //Case 5-2
                    }
                    else if (boolBegIn == false & boolEndIn == false)
                    {
                        dblPntBeg = dblPntInts[0];
                        double elev = EW_Utility2.getElev(dblPntBeg, id3dBndry);

                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntBeg.X, dblPntBeg.Y);
                        }
                        dblPntBeg = dblPntBeg.addElevation(elev);

                        dblPntEnd = dblPntInts[1];
                        elev      = EW_Utility2.getElev(dblPntEnd, id3dBndry);
                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntEnd.X, dblPntEnd.Y);
                        }
                        dblPntEnd = dblPntEnd.addElevation(elev);

                        boolAddEnt = true;
                        intCase5_2 = intCase5_2 + 1;
                        //Case 5-3
                    }
                    else if (boolBegOnSeg == true & boolEndIn == false)
                    {
                        dblPntBeg = dblPntInts[0];
                        double elev = EW_Utility2.getElev(dblPntBeg, id3dBndry);

                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntBeg.X, dblPntBeg.Y);
                        }
                        dblPntBeg = dblPntBeg.addElevation(elev);

                        dblPntEnd = dblPntInts[1];
                        elev      = EW_Utility2.getElev(dblPntEnd, id3dBndry);
                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntEnd.X, dblPntEnd.Y);
                        }
                        dblPntEnd = dblPntEnd.addElevation(elev);

                        boolAddEnt = true;
                        intCase5_3 = intCase5_3 + 1;
                        //Case 5-4
                    }
                    else if (boolEndOnSeg == true & boolBegIn == false)
                    {
                        dblPntBeg = dblPntInts[0];
                        double elev = EW_Utility2.getElev(dblPntBeg, id3dBndry);

                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntBeg.X, dblPntBeg.Y);
                        }
                        dblPntBeg = dblPntBeg.addElevation(elev);

                        dblPntEnd = dblPntInts[1];
                        elev      = EW_Utility2.getElev(dblPntEnd, id3dBndry);
                        if (elev == 0 && strSurfaceName == "SG")
                        {
                            elev = objSurfaceSG.FindElevationAtXY(dblPntEnd.X, dblPntEnd.Y);
                        }
                        dblPntEnd  = dblPntEnd.addElevation(elev);
                        boolAddEnt = true;
                        intCase5_4 = intCase5_4 + 1;
                        //Case 5-5
                    }
                    else if (boolBegIn == true & boolEndIn == true)
                    {
                        boolAddEnt = true;
                        intCase5_5 = intCase5_5 + 1;
                    }

                    break;

                case 3:
                    //Case 8
                    List <Point3d> dblPntInts_New = new List <Point3d>();
                    for (int s = dblPntInts.Count; s > 0; s--)
                    {
                        if (System.Math.Round(dblPntBeg.X, 3) == System.Math.Round(dblPntInts[s - 1].X, 3) &&
                            System.Math.Round(dblPntBeg.Y, 3) == System.Math.Round(dblPntInts[s - 1].Y, 3))
                        {
                            dblPntInts.RemoveAt(s - 1);
                        }
                    }

                    for (int s = dblPntInts.Count; s > 0; s--)
                    {
                        if (System.Math.Round(dblPntEnd.X, 3) == System.Math.Round(dblPntInts[s - 1].X, 3) &&
                            System.Math.Round(dblPntEnd.Y, 3) == System.Math.Round(dblPntInts[s - 1].Y, 3))
                        {
                            dblPntInts.RemoveAt(s - 1);
                        }
                    }

                    switch (dblPntInts.Count)
                    {
                    case 2:

                        double dblDist1 = dblPntBeg.getDistance(dblPntInts[0]);
                        double dblDist2 = dblPntBeg.getDistance(dblPntInts[1]);

                        if (dblDist1 > dblDist2)
                        {
                            Point3d pnt3dTmp = dblPntInts[0];
                            dblPntInts[0] = dblPntInts[1];
                            dblPntInts[1] = pnt3dTmp;
                        }

                        Point3d dblPntMid = dblPntBeg + (dblPntInts[0] - dblPntBeg) / 2;

                        if (dblPntMid.isInside(varPnts3dBndry0zForInt))
                        {
                            Point3d        dblPntInt    = dblPntInts[0];
                            List <Point3d> dblPnts3dBrk = new List <Point3d>();
                            dblPnts3dBrk.Add(dblPntBeg);
                            double elev = EW_Utility2.getElev(dblPntInt, id3dBndry);

                            if (elev == 0.0 && strSurfaceName == "SG")
                            {
                                elev = objSurfaceSG.FindElevationAtXY(dblPntInt.X, dblPntInt.Y);
                            }
                            dblPntInt.addElevation(elev);
                            dblPnts3dBrk.Add(dblPntInt);

                            ObjectId id3dBrkXNew = Draw.addPoly3d(dblPnts3dBrk, strSurfaceNameX + "-BRKLINE");
                            id3dBrkXNew.changeProp(LineWeight.ByLayer, Color.FromColorIndex(ColorMethod.ByAci, 0));
                            id3dBrkXNew.setXData(tvs, "makeBOT");

                            intCase5_1 = intCase5_1 + 1;

                            id3dBrkX.delete();
                        }

                        dblPntMid = dblPntInts[1] + (dblPntEnd - dblPntInts[1]) / 2;
                        if (dblPntMid.isInside(varPnts3dBndry0zForInt))
                        {
                            Point3d        dblPntInt    = dblPntInts[1];
                            List <Point3d> dblPnts3dBrk = new List <Point3d>();
                            double         elev         = EW_Utility2.getElev(dblPntInt, id3dBndry);

                            if (elev == 0.0 && strSurfaceName == "SG")
                            {
                                elev = objSurfaceSG.FindElevationAtXY(dblPntInt.X, dblPntInt.Y);
                            }
                            dblPntInt.addElevation(elev);
                            dblPnts3dBrk.Add(dblPntInt);
                            dblPnts3dBrk.Add(dblPntEnd);

                            ObjectId id3dBrkXNew = Draw.addPoly3d(dblPnts3dBrk, strSurfaceNameX + "-BRKLINE");
                            id3dBrkXNew.changeProp(LineWeight.ByLayer, Color.FromColorIndex(ColorMethod.ByAci, 0));
                            id3dBrkXNew.setXData(tvs, "makeBOT");

                            intCase8_5 = intCase8_5 + 1;

                            id3dBrkX.delete();
                        }

                        break;

                    case 3:

                        break;
                    }

                    break;

                case 4:
                    //Case 11

                    intCase11 = intCase11 + 1;

                    break;

                case -9:

                    boolAddEnt = false;

                    break;
                }

                if (boolAddEnt == true)
                {
                    id3dBrkX.delete();
                    id3dBrkP = Draw.addPoly3d(dblPntBeg, dblPntEnd, strLayer);
                    id3dBrkP.setXData(tvs, "makeBOT");

                    if (pub.boolDebug)
                    {
                        id3dBrkX.changeProp(LineWeight.LineWeight200, clr.byl);
                        id3dBrkP = id3dBrkX;
                    }
                }
                else
                {
                    //      obj3dBrkX.Delete
                }

                if (pub.boolDebug)
                {
                    idTextB.delete();
                    idTextE.delete();

                    ss = EW_Utility1.buildSSet7();
                    ss.eraseSelectedItems();
                }
            }

            //Debug.Print "Case -1 " & intCase1
            //Debug.Print "Case 2-1 " & intCase2_1
            //Debug.Print "Case 2-2 " & intCase2_2
            //Debug.Print "Case 2-3 " & intCase2_3
            //Debug.Print "Case 2-4 " & intCase2_4
            //Debug.Print "Case 2-5 " & intCase2_5
            //Debug.Print "Case 2-6 " & intCase2_6
            //Debug.Print "Case 2-7 " & intCase2_7
            //Debug.Print "Case 2-8 " & intCase2_8
            //Debug.Print "Case 5-1 " & intCase5_1
            //Debug.Print "Case 5-2 " & intCase5_2
            //Debug.Print "Case 5-3 " & intCase5_3
            //Debug.Print "Case 5-4 " & intCase5_4
            //Debug.Print "Case 5-5 " & intCase5_5
            //Debug.Print "Case 8-5 " & intCase8_5
            //Debug.Print "Case 8-8 " & intCase8_8
            //Debug.Print "Case 11 " & intCase11
            //Debug.Print "Total=" & intCase1 + intCase2_1 + intCase2_2 + intCase2_3 + intCase2_4 + intCase2_5 + intCase2_6 + _
            //'            intCase2_7 + intCase2_8 + intCase5_1 + intCase5_2 + intCase5_3 + intCase5_4 + intCase5_5 + _
            //'            intCase8_5 + intCase8_8 + intCase11

            return(true);
        }
Пример #14
0
        public static void makeSurfaceOX()
        {
            bool boolFirstPass = false;

            timeBeg = DateTime.Now;

            Layer.manageLayers("SG-BRKLINE");
            Layer.manageLayers("_YY-BLDG LIM");

            SelectionSet objSSetBLDG_LIM = EW_Utility1.buildSSetBLDG_LIM();             //get _YY-BLDG LIM(s)

            SelectionSet objSSetFLOOR_SLAB = EW_Utility1.buildSSetFLOOR_SLAB();         //get _XX-FLOOR SLAB(s)

            if (objSSetBLDG_LIM.Count == 0)
            {
                //  For i = 0 To objSSetFLOOR_SLAB.Count - 1
                //
                //    Set objFLOORSLAB = objSSetFLOOR_SLAB.Item(i)
                //    strLayer = objFLOORSLAB.Layer
                //
                //    objFLOORSLAB.Closed = False
                //    Call forceClosed(objFLOORSLAB)
                //
                //    varXDataVal = Empty
                //    objFLOORSLAB.getXdata "OX", varXDataType, varXDataVal
                //
                //    If Not IsEmpty(varXDataVal) Then
                //      intBldgNo = varXDataVal(1)
                //    Else
                //      intBldgNo = i
                //    End If
                //
                //    Set objBldgOX2 = getBldgOX2(objFLOORSLAB, intBldgNo, "MAKE", strLayer)               'get BLDG OX limits
                //    objBldgOX2.color = acMagenta
                //    objBldgOX2.Lineweight = acLnWt100
                //
                //    If i = 0 Then
                //      boolFirstPass = True
                //    Else
                //      boolFirstPass = False
                //    End If
                //
                //    Call modAdjacentAreas_Subtract(objBldgOX2, boolFirstPass)                        'get modified areas adjacent to BLDG OX limits
                //
                //  Next i
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("There are Zero BLDG LIMs - there needs to be one BLDG LIM for each Building.  Exiting...");
                return;
                //BLDG LIM exists
            }
            else
            {
                color = Misc.getColorByBlock(6);
                ObjectId[] ids = objSSetBLDG_LIM.GetObjectIds();

                for (int i = 0; i < ids.Length; i++)
                {
                    string strLayer = EW_Build3dPoly.getBldgLayer(ids[i]);
                    //FOR EACH BLDG LIM GET CORRESPONDING FLOOR SLAB
                    //as is will return last bldg area inside BLDG LIM if more than one FLOOR SLAB

                    ObjectId idBldgOX2 = EW_GetBldgOX2.getBldgOX2(ids[i], 1, "MADE", strLayer);                    //get BLDG OX limits

                    if ((idBldgOX2 == ObjectId.Null))
                    {
                        return;
                    }

                    idBldgOX2.changeProp(LineWeight.LineWeight100, color);

                    if (i == 0)
                    {
                        boolFirstPass = true;                         //FOR MULTIPLE BUILDINGS
                    }
                    else
                    {
                        boolFirstPass = false;
                    }
                    EW_ModAdjacentAreas.modAdjacentAreas_Subtract(idBldgOX2, boolFirstPass);                     //build modified areas adjacent to BLDG OX limits
                }
                //  If objSSetBLDG_LIM.Count <> objSSetFLOOR_SLAB.Count Then
                //    MsgBox "Number of Building Limit not equal to Number of FLOOR SLAB"
                //  End If
            }

            SelectionSet ss = EW_Utility1.buildSSet22();              //OX-LIM-OUTER

            ObjectId[] idsOX_LIM_OUTER = ss.GetObjectIds();

            for (int i = 0; i < idsOX_LIM_OUTER.Length; i++)
            {
                ObjectId idBldgOX2 = idsOX_LIM_OUTER[i];

                Point3dCollection varPnts3d = idBldgOX2.getCoordinates3d();

                ss = EW_Utility1.buildSSet21(varPnts3d);                    //get OX-AREAS-2d - inside OX limit for removal
                ObjectId[] idsAreas = ss.GetObjectIds();
                for (int j = 0; j < idsAreas.Length; j++)
                {
                    idsAreas[j].changeProp(LineWeight.LineWeight050, clr.red);
                    idsAreas[j].delete();                     //delete areas inside OX-LIM-OUTER
                }
            }

            ss = EW_Utility1.buildSSet19();             //get OX-AREAS-2d - select all
            ObjectId[] idsOX_AREAS_2d = ss.GetObjectIds();

            for (int i = 0; i < idsOX_AREAS_2d.Length; i++)
            {
                ObjectId idLWPlineT = idsOX_AREAS_2d[i];
                idLWPlineT.changeProp(LineWeight.LineWeight000, clr.wht);

                ResultBuffer rb = idLWPlineT.getXData("OX-Layer");
                if (rb == null)
                {
                    continue;
                }

                string strLayer = rb.AsArray()[1].Value.ToString();

                color = Misc.getColorByBlock(140);
                ObjectId idLWPlineX = idLWPlineT.offset(-0.05);
                if (idLWPlineX == ObjectId.Null)
                {
                    idLWPlineT.changeProp(LineWeight.LineWeight200, color);
                    continue;
                }
                else
                {
                    idLWPlineX.changeProp(LineWeight.LineWeight100, clr.mag);
                    idLWPlineT.delete();

                    if (!offsetSegments("SG", "OX", idLWPlineX, strLayer))
                    {
                        return;
                    }
                }
            }

            viewResults("OX", true);

            if (!pub.boolDebug)
            {
                ss = EW_Utility1.buildSSetOX2d();
                ss.eraseSelectedItems();
            }

            ss = EW_Utility1.buildSSetLinesLayer0();
            ss.eraseSelectedItems();
        }
Пример #15
0
        public static void makeSurfaceSG()
        {
            //Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.Command("_ucs", "w", "");
            BaseObjs.sendCommand("_ucs\rw\r");
            TinSurface objSurfaceCPNT = Surf.getTinSurface("CPNT-ON", out exists);

            SelectionSet objSSet = null;

            if (pub.boolDebug)
            {
                objSSet = EW_Utility1.buildSSet1();                 //SelectOnScreen _XX-*
            }
            else
            {
                objSSet = EW_Utility1.buildSSet0();                 //get _XX-*
            }
            if (objSSet == null || objSSet.Count == 0)
            {
                return;
            }

            ObjectId[] ids = objSSet.GetObjectIds();

            timeBeg = DateTime.Now;

            ObjectId idPolyT = ObjectId.Null;

            for (int i = 0; i < ids.Length; i++)
            {
                Polyline objLWPline = (Polyline)ids[i].getEnt();

                ObjectId idLWPlineT = objLWPline.copy();
                if (idLWPlineT.IsNull)
                {
                    MessageBox.Show("Null Id @ line 131 EW_Main");
                    continue;
                }

                idLWPlineT.changeProp(LineWeight.LineWeight050, clr.yel);

                if (objLWPline.HasBulges)
                {
                    idPolyT = Conv.processBndry(idLWPlineT);                        //boundary with arcs converted to line segments
                    idLWPlineT.delete();
                }
                else
                {
                    Entity ent = idLWPlineT.getEnt();
                    idPolyT = ent.ObjectId;
                }

                //Entity entx = idPolyT.getEnt();
                //MessageBox.Show(entx.GetType().ToString());

                switch (objLWPline.Layer)
                {
                case "_XX-FLOOR SLAB_A":
                case "_XX-FLOOR SLAB_B":
                case "_XX-FLOOR SLAB_C":
                case "_XX-DOCK APRON":
                    color = clr.yel;
                    break;

                default:
                    color = clr.grn;
                    break;
                }

                ObjectId idLWPlineX = ObjectId.Null;
                if (!objLWPline.Layer.Contains("_XX-FLOOR"))
                {
                    idLWPlineX = idPolyT.offset(-0.05);
                    idPolyT.delete();
                }
                else
                {
                    idLWPlineX = idPolyT;
                }

                if (idLWPlineX.IsNull)
                {
                    MessageBox.Show("Null Id @ line 162 EW_Main" + idPolyT.getHandle().ToString());
                    continue;
                }

                idLWPlineX.changeProp(LineWeight.LineWeight060, color);


                if (!offsetSegments("CPNT-ON", "SG", idLWPlineX, objLWPline.Layer))
                {
                    return;
                }
            }

            viewResults("SG", true);
        }
Пример #16
0
        public static void testBotElev(object[] varGridData, bool boolReTest)
        {
            bool boolProceed = false;
            bool isOX        = false;
            bool isOXg       = false;

            double dblPntXmin  = (double)(varGridData[0]);
            double dblPntYmin  = (double)(varGridData[1]);
            int    intInterval = (int)varGridData[2];

            Layer.manageLayers("BOT-POINTS");

            TinSurface objSurfaceSG = Surf.getTinSurface("SG");

            if (objSurfaceSG == null)
            {
                MessageBox.Show("Surface SG is missing.  Exiting ......");
                return;
            }

            TinSurface objSurfaceOX = Surf.getTinSurface("OX");

            if (objSurfaceOX == null)
            {
                MessageBox.Show("Surface OX is missing.  Exiting ......");
            }

            TinSurface objSurfaceOXg = Surf.getTinSurface("OXg");

            if (objSurfaceOXg != null)
            {
                isOXg = true;
            }

            EW_Utility1.getTableData();
            TinSurface objSurfaceEXIST = null;

            if (p.REMOVE_REPLACE_BLDG_V == -1)
            {
                objSurfaceEXIST = Surf.getTinSurface("NATIVE");
                if (objSurfaceEXIST == null)
                {
                    MessageBox.Show("NATIVE surface missing while Remove and Replace values are 0.  Exiting routine..........");
                    return;
                }
            }
            else
            {
                objSurfaceEXIST = Surf.getTinSurface("EXIST");
                if (objSurfaceEXIST == null)
                {
                    objSurfaceEXIST = Surf.getTinSurface("exist");
                    if (objSurfaceEXIST == null)
                    {
                        MessageBox.Show("Surface EXIST missing.  Exiting routine......");
                        return;
                    }
                }
            }

            SurfaceDefinitionBoundaries bndrys = objSurfaceEXIST.BoundariesDefinition;

            for (int i = 0; i < bndrys.Count; i++)
            {
                if (bndrys[i].BoundaryType == Autodesk.Civil.SurfaceBoundaryType.Hide)
                {
                    MessageBox.Show("Surface EXIST is using HIDE Boundaries - exiting program");
                    return;
                }
            }

            try {
                SelectionSet objSSet = null;
                if (p.boolDebug)
                {
                    objSSet = EW_Utility1.buildSSet2b("OX");                     //GET "OX-BRKLINE* by select
                }
                else
                {
                    if (isOX)
                    {
                        objSSet = EW_Utility1.buildSSet2a("OX");                         //GET "OX-BRKLINE*
                    }
                    else
                    {
                        objSSet = EW_Utility1.buildSSet2a("SG");                         //GET "SG-BRKLINE*
                    }
                }

                //BEGIN BOUNDARY EDIT - ADD X GRID POINTS

                ObjectId[] ids = objSSet.GetObjectIds();
                for (int i = 0; i < ids.Length; i++)
                {
                    ObjectId id3dBndry_Org = ids[i];

                    if (p.boolDebug)
                    {
                        id3dBndry_Org.changeProp(LineWeight.LineWeight020, clr.c70);
                    }

                    ResultBuffer rb = id3dBndry_Org.getXData("makeBOT");
                    if (rb == null)
                    {
                        continue;
                    }
                    TypedValue[] tvs     = rb.AsArray();
                    string       strType = "";
                    try {
                        strType = tvs[2].Value.ToString();
                    }
                    catch (System.Exception) {
                        strType = "K-BRACE";
                    }

                    rb = id3dBndry_Org.getXData("OX");
                    if (rb == null)
                    {
                        continue;
                    }
                    tvs = rb.AsArray();

                    try {
                        string strSource = tvs[1].Value.ToString();
                        switch (strSource)
                        {
                        case "OX1":
                            strType = "OX1";
                            break;

                        case "OX2":
                            strType = "OX2";
                            break;

                        case "OX3":
                            strType = "OX3";
                            break;

                        case "OX4":
                            strType = "OX4";
                            break;
                        }
                    }
                    catch (System.Exception) {
                    }

                    List <Point3d> varPnts3dBndry = id3dBndry_Org.getCoordinates3dList();

                    int k = varPnts3dBndry.Count;

                    List <Point3d> dblPnts3dBndry = new List <Point3d>();
                    Point3d        pnt3d          = new Point3d(varPnts3dBndry[0].X, varPnts3dBndry[0].Y, 0.0);
                    dblPnts3dBndry.Add(pnt3d);

                    int intXCounter = 0, intYCounter = 0;

                    for (int j = 1; j < k; j++)
                    {
                        Point3d pnt3dBeg = varPnts3dBndry[j - 1];
                        Point3d pnt3dEnd = varPnts3dBndry[j - 0];

                        double dblLEN = pnt3dBeg.getDistance(pnt3dEnd);
                        if (dblLEN > 5)
                        {
                            double dblAngle = pnt3dBeg.getDirection(pnt3dEnd);

                            int intXbeg = (int)((pnt3dBeg.X - dblPntXmin) / intInterval);
                            int intXend = (int)((pnt3dEnd.X - dblPntXmin) / intInterval);
                            if (intXend - intXbeg > 0)
                            {
                                intXCounter = 1;
                                intXbeg++;
                                boolProceed = true;
                            }
                            else if (intXend - intXbeg < 0)
                            {
                                intXCounter = -1;
                                intXend++;
                                boolProceed = true;
                            }
                            else if (intXend - intXbeg == 0)
                            {
                                intXCounter = -1;
                                boolProceed = false;
                            }

                            if (boolProceed == true)
                            {
                                for (int n = intXbeg; n <= intXend; n += intXCounter)
                                {
                                    double dblX = dblPntXmin + n * intInterval;
                                    double dblY = pnt3dBeg.Y + (dblX - pnt3dBeg.X) * System.Math.Tan(dblAngle);
                                    pnt3d = new Point3d(dblX, dblY, 0);

                                    if (p.boolDebug)
                                    {
                                        Draw.addCircle(pnt3d, 1, "DEBUG-0", (short)3);
                                    }

                                    dblPnts3dBndry.Add(pnt3d);
                                }
                            }

                            pnt3d = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, 0.0);
                            dblPnts3dBndry.Add(pnt3d);

                            if (p.boolDebug)
                            {
                                Draw.addCircle(pnt3d, 1, "DEBUG-0", (short)3);
                            }
                        }
                        else
                        {
                            pnt3d = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, 0.0);
                            dblPnts3dBndry.Add(pnt3d);

                            if (p.boolDebug)
                            {
                                Draw.addCircle(pnt3d, 1, "DEBUG-0", (short)2);
                            }
                        }
                    }

                    //END BOUNDARY EDIT - ADD X GRID POINTS

                    varPnts3dBndry = dblPnts3dBndry;
                    k = varPnts3dBndry.Count;

                    //BEGIN BOUNDARY EDIT - ADD Y GRID POINTS
                    dblPnts3dBndry = new List <Point3d>();
                    dblPnts3dBndry.Add(varPnts3dBndry[0]);                     //keep first point

                    if (p.boolDebug)
                    {
                        Draw.addCircle(dblPnts3dBndry[0], 1, "DEBUG-0", (short)1);
                    }

                    for (int x = 0; x < k; x++)
                    {
                        Point3d pnt3dBeg = varPnts3dBndry[x - 1];
                        Point3d pnt3dEnd = varPnts3dBndry[x - 0];

                        double dblLEN = pnt3dBeg.getDistance(pnt3dEnd);

                        if (dblLEN > 5)
                        {
                            double dblAngle = pnt3dBeg.getDirection(pnt3dEnd);

                            int intYbeg = (int)((pnt3dBeg.Y - dblPntYmin) / intInterval);
                            int intYend = (int)((pnt3dEnd.Y - dblPntYmin) / intInterval);

                            if (intYend - intYbeg > 0)
                            {
                                intYCounter = (short)1;
                                intYbeg++;
                                boolProceed = true;
                            }
                            else if (intYend - intYbeg < 0)
                            {
                                intYCounter = (short)(-1);
                                intYend++;
                                boolProceed = true;
                            }
                            else if (intYend - intYbeg == ((short)0))
                            {
                                intYCounter = (short)(-1);
                                boolProceed = false;
                            }

                            if (boolProceed == true)
                            {
                                for (k = intYbeg; k <= intYend; k += intYCounter)
                                {
                                    double dblY = dblPntYmin + k * intInterval;
                                    double dblX = pnt3dBeg.X + (dblY - pnt3dBeg.Y) / System.Math.Tan(dblAngle);
                                    pnt3d = new Point3d(dblX, dblY, 0.0);

                                    if (p.boolDebug)
                                    {
                                        Draw.addCircle(pnt3d, 1, "DEBUG-0", (short)2);
                                    }
                                    dblPnts3dBndry.Add(pnt3d);
                                }
                            }

                            dblPnts3dBndry.Add(pnt3dEnd);

                            if (p.boolDebug)
                            {
                                Draw.addCircle(pnt3dEnd, 1, "DEBUG-0", (short)3);
                            }
                        }
                        else
                        {
                            dblPnts3dBndry.Add(pnt3dEnd);

                            if (p.boolDebug)
                            {
                                Draw.addCircle(pnt3dEnd, 1, "DEBUG-0", (short)2);
                            }
                        }
                    }

                    //END BOUNDARY EDIT - ADD Y GRID POINTS

                    //BEGIN REMOVE DUPLICATE POINTS

                    List <Point3d> dblPnts3dBndryRev = new List <Point3d>();
                    dblPnts3dBndryRev.Add(dblPnts3dBndry[0]);

                    for (int j = 1; j < dblPnts3dBndry.Count; j++)
                    {
                        if (System.Math.Round(dblPnts3dBndry[j - 1].X, 3) == System.Math.Round(dblPnts3dBndry[j - 0].X, 3) &&
                            System.Math.Round(dblPnts3dBndry[j - 1].Y, 3) == System.Math.Round(dblPnts3dBndry[j - 0].Y, 3))
                        {
                            //do nothing
                        }
                        else
                        {
                            dblPnts3dBndryRev.Add(dblPnts3dBndry[j]);
                        }
                    }

                    //END REMOVE DUPLICATE POINTS

                    //BEGIN TEST ELEVATION ON BOUNDARY

                    k = dblPnts3dBndryRev.Count;

                    if (k > 3)
                    {
                        for (int j = 0; j < k; j++)
                        {
                            pnt3d = dblPnts3dBndryRev[j];

                            double dblZ_EXIST = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceEXIST);
                            double dblZ_R_R   = 0;
                            if (isOX)
                            {
                                dblZ_R_R = dblZ_EXIST - p.REMOVE_REPLACE_BLDG_V;
                            }
                            else
                            {
                                dblZ_R_R = dblZ_EXIST - p.REMOVE_REPLACE_V;
                            }

                            double dblZ_SG  = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceSG);
                            double dblZ_OX  = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceOX);
                            double dblZ_OXg = 0;
                            if (isOXg)
                            {
                                dblZ_OXg = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceOXg);
                            }

                            double dblZ_MIN = dblZ_R_R;

                            if (dblZ_SG < dblZ_MIN)
                            {
                                dblZ_MIN = dblZ_SG;
                            }

                            if (dblZ_OX < dblZ_MIN)
                            {
                                dblZ_MIN = dblZ_OX;
                            }

                            if (isOXg)
                            {
                                if (dblZ_OXg < dblZ_MIN)
                                {
                                    dblZ_MIN = dblZ_OXg;
                                }
                            }

                            if (dblZ_MIN <= 0)
                            {
                                Draw.addCircle(pnt3d, 1, "DEBUG-0", (short)1);
                                pnt3d = pnt3d.addElevation(dblZ_R_R);
                                dblPnts3dBndryRev.Add(pnt3d);
                            }
                            else
                            {
                                pnt3d = pnt3d.addElevation(dblZ_MIN);
                                dblPnts3dBndryRev.Add(pnt3d);
                            }
                        }

                        ObjectId id3dBndry = Draw.addPoly3d(dblPnts3dBndryRev);

                        if (strType == "LIM" || strType == "K-BRACE")
                        {
                            id3dBndry.changeProp(clr.byl, "BOT-BRKLINE-AREA");
                        }
                        else if (strType == "BRKLINES")
                        {
                            id3dBndry.changeProp(clr.byl, "BOT-BRKLINE");
                        }
                    }

                    //END TEST ELEVATION ON BOUNDARY

                    //BEGIN TEST ELEVATION ON GRID POINTS
                    List <string> excludes           = new List <string>()
                    {
                        "BRKLINES", "OX2", "OX3", "OX4"
                    };
                    if (excludes.Contains(strType))
                    {
                        continue;
                    }
                    else
                    {
                        k = dblPnts3dBndryRev.Count;
                        dblPnts3dBndryRev.RemoveAt(k - 1);

                        Point3dCollection varPnts3dBndryCol = new Point3dCollection();
                        foreach (Point3d pnt in dblPnts3dBndryRev)
                        {
                            pnt.addElevation(0.0);
                            varPnts3dBndryCol.Add(pnt);
                        }

                        varPnts3dBndry = dblPnts3dBndryRev;

                        SelectionSet objSSetX = EW_Utility1.buildSSet11(varPnts3dBndryCol);                         //select points by polygon crossing
                        ids = objSSetX.GetObjectIds();

                        if (strType == "_XX-BUILDING ADJACENT LANDSCAPING")
                        {
                            //do nothing i.e. do not assign point description "BOT"
                        }
                        else
                        {
                            for (int j = 0; j < ids.Length; j++)
                            {
                                pnt3d = ids[j].getCogoPntCoordinates();

                                if (pnt3d.isInside(dblPnts3dBndryRev))
                                {
                                    double dblZ_EXIST = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceEXIST);
                                    double dblZ_R_R   = 0;

                                    if (isOX)
                                    {
                                        dblZ_R_R = dblZ_EXIST - p.REMOVE_REPLACE_BLDG_V;
                                    }
                                    else
                                    {
                                        dblZ_R_R = dblZ_EXIST - p.REMOVE_REPLACE_V;
                                    }

                                    double dblZ_SG  = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceSG);
                                    double dblZ_OX  = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceOX);
                                    double dblZ_OXg = 0;
                                    if (isOXg)
                                    {
                                        dblZ_OXg = EW_Utility2.getSurfaceElev(pnt3d.X, pnt3d.Y, objSurfaceOXg);
                                    }

                                    if (dblZ_OX < 0)
                                    {
                                        dblZ_OX = dblZ_SG;
                                    }

                                    double dblZ_MIN = dblZ_R_R;

                                    if (dblZ_SG < dblZ_MIN)
                                    {
                                        dblZ_MIN = dblZ_SG;
                                    }

                                    if (dblZ_OX < dblZ_MIN)
                                    {
                                        dblZ_MIN = dblZ_OX;
                                    }

                                    if (isOXg)
                                    {
                                        if (dblZ_OXg < dblZ_MIN)
                                        {
                                            dblZ_MIN = dblZ_OXg;
                                        }
                                    }

                                    using (var tr = BaseObjs.startTransactionDb()) {
                                        CogoPoint cgPnt = (CogoPoint)tr.GetObject(ids[j], OpenMode.ForRead);
                                        cgPnt.Elevation      = dblZ_MIN;
                                        cgPnt.RawDescription = "BOT";
                                        cgPnt.Layer          = "BOT-POINTS";
                                        cgPnt.StyleId        = CgPnts.getPntStyle("BOT").ObjectId;
                                        cgPnt.LabelStyleId   = CgPnts.getPntLabelStyle("BOT");
                                    }
                                }
                            }
                        }
                    }
                    //END TEST ELEVATION ON GRID POINTS+``````````
                }

                if (boolReTest == false)
                {
                    EW_Main.viewResults("BOT", false);
                }
            }
            catch {
            }
            return;
        }
Пример #17
0
        addExcelWorkbook()
        {
            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = string.Format("{0}\\{1}", Path.GetDirectoryName(strPath), strFN);
            string mess        = string.Format("{0} exists. Overwrite existing file? Y/N", strFN);

            if (FileSystem.FileExists(strFullPath))
            {
                DialogResult varResponse = MessageBox.Show(mess, "File exists!", MessageBoxButtons.YesNo);

                switch (varResponse)
                {
                case DialogResult.Yes:

                    try {
                        FileSystem.DeleteFile(strFullPath);
                    } catch (Exception) {
                        MessageBox.Show("Error deleting existing file - good luck");
                        return;
                    }

                    FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                    mess = string.Format("{0} created in {1} folder.", strFN, strPath);
                    MessageBox.Show(mess);

                    break;

                case DialogResult.No:

                    break;                            //do nothing
                }
            }
            else
            {
                FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                mess = string.Format("{0} created in {1} folder.", strFN, strPath);
                MessageBox.Show(mess);
            }

            Excel_ext excl = new Excel_ext(true);

            excl.OpenFile(strFullPath, "");
            excl.FindExcelWorksheet("SUMMARY");
            Excel._Worksheet objWS = excl.excelWrkSht;

            ProjectData varProjectData = Misc.getProjectData(strJN);

            if (varProjectData.Name.ToString() != string.Empty)
            {
                objWS.Range["SUMMARY!SITE_NAME"].Value = varProjectData.Name;
                objWS.Range["SUMMARY!LOCATION"].Value  = varProjectData.Location;
                objWS.Range["SUMMARY!CLIENT"].Value    = varProjectData.Client;

                objWS.Range["SUMMARY!JOB_NUMBER"].Value  = varProjectData.Number;
                objWS.Range["SUMMARY!COORDINATOR"].Value = varProjectData.Coordinator;
                objWS.Range["SUMMARY!SOURCE"].Value      = BaseObjs.docName;
            }

            double dblAreaPad = 0;
            int    intCount   = 0;

            SelectionSet objSSet  = EW_Utility1.buildSSetTable();
            Table        objTable = (Table)objSSet.GetObjectIds()[0].getEnt();

            if (EW_Pub.OX_LIMIT_H == 0)
            {
                EW_Pub.OX_LIMIT_H = double.Parse(objTable.Cells[20, 1].Value.ToString());
            }

            objSSet = EW_Utility1.buildSSetBLDG_LIM();

            foreach (ObjectId idBldgLim in objSSet.GetObjectIds())
            {
                ObjectId idBldgLimOffset = idBldgLim.offset(EW_Pub.OX_LIMIT_H);

                if ((idBldgLimOffset.IsNull))
                {
                    intCount++;
                }
                else
                {
                    dblAreaPad = dblAreaPad + idBldgLimOffset.getArea();
                    idBldgLimOffset.delete();
                }
            }

            if (intCount > 0)
            {
                MessageBox.Show(string.Format("{0} Building Limit Area(s) failed.  Requires manual calculation.", intCount));
            }

            objWS.Range["SUMMARY!AREA_PAD"].Value = (int)dblAreaPad;

            double   dblAreaSite   = 0;
            Polyline objGradingLim = default(Polyline);

            objSSet       = EW_Utility1.buildSSetGradingLim();
            objGradingLim = (Polyline)objSSet.GetObjectIds()[0].getEnt();
            dblAreaSite   = objGradingLim.Area;

            objWS.Range["SUMMARY!AREA_SITE"].Value = (int)dblAreaSite;

            excl.CloseFile(true, strFullPath, false);
        }
Пример #18
0
        checkAreaLimit(SelectionSet objSSetAreas, ObjectId idGradingLim)
        {
            Polyline objGradingLim = (Polyline)idGradingLim.getEnt();

            bool   boolPass   = true;
            Color  color      = null;
            double dblAreaSum = 0;
            int    k          = 0;

            if (objSSetAreas == null)
            {
                return(false);
            }
            ObjectId[] ids = objSSetAreas.GetObjectIds();

            for (int i = 0; i < ids.Length; i++)
            {
                Polyline objLWPoly = (Polyline)ids[i].getEnt();


                if (objLWPoly.Area == 0)
                {
                    ids[i].delete();
                }
                else
                {
                    EW_Utility1.removeDuplicateVertex(ref objLWPoly);

                    dblAreaSum = dblAreaSum + objLWPoly.Area;

                    List <Point3d> pnts3d = objLWPoly.ObjectId.getCoordinates3dList();

                    for (int j = 1; j < pnts3d.Count - 1; j++)
                    {
                        Point3d pnt3dBack = pnts3d[j - 1];
                        Point3d pnt3dX    = pnts3d[j - 0];
                        Point3d pnt3dAhed = pnts3d[j + 1];

                        double dblAngBack  = pnt3dX.getDirection(pnt3dBack);
                        double dblAngAhead = pnt3dX.getDirection(pnt3dAhed);


                        if (System.Math.Abs(System.Math.Round(dblAngAhead - dblAngBack, 3)) == System.Math.Round(pi, 3))
                        {
                            ObjectId idCircle = Draw.addCircle(pnt3dX, 2);
                            k++;
                            color = new Color();
                            color = Color.FromColorIndex(ColorMethod.ByBlock, (short)k);
                            string mess = string.Format("Unnecessary vertex at:  X={0}, Y={1}", pnts3d[j].X, pnts3d[j].Y);
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(mess);

                            idCircle.changeProp(LineWeight.LineWeight100, color);
                            boolPass = false;
                        }
                    }
                }
            }

            double dblAreaLim = objGradingLim.Area;
            string msg        = "";

            if (dblAreaLim - dblAreaSum > dblAreaLim * 0.05)
            {
                msg = string.Format("Grading Limit area: {0} is greater than the sum of the areas: {1}", dblAreaLim, dblAreaSum);
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(msg);
                boolPass = false;
            }

            if (dblAreaSum - dblAreaLim > dblAreaLim * 0.05)
            {
                msg = string.Format("The sum of the areas: {0} is greater than the Grading Limit area: {1}", dblAreaSum, dblAreaLim);
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(msg);
                boolPass = false;
            }

            if (boolPass)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Area Limits Passed Inspection.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #19
0
        getBldgOX2(ObjectId idLWPline_LIM, int intBldgNo, string strOption, string strLayer)
        {
            bool       exists;
            TinSurface surf = Surf.getTinSurface("CPNT-ON", out exists);

            TypedValue[] tvs = new TypedValue[3] {
                new TypedValue(1001, "OX"),
                new TypedValue(1000, intBldgNo),
                new TypedValue(1000, "OX0")
            };

            Layer.manageLayers("OX-LIM-OUTER");
            Layer.manageLayers("OX-AREAS-BLDG");
            Layer.manageLayers("OX-AREAS-2d");

            if (!idLWPline_LIM.isRightHand())
            {
                idLWPline_LIM.reversePolyX();
            }


            //BLDGOX0
            Color    color     = Misc.getColorByBlock(7);
            ObjectId idBldgOX0 = ObjectId.Null;

            if (strOption == "MAKE")
            {
                Polyline objBldgOX0 = (Polyline)Misc.getBldgLimitsEW(idLWPline_LIM);                 //returns BldgOX0 2dPolyline
                idBldgOX0 = objBldgOX0.ObjectId;
                //outer limit of building footprint
                idBldgOX0.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

                idBldgOX0.checkIfClosed();

                if (!idBldgOX0.isRightHand())
                {
                    idBldgOX0.reversePolyX();
                }
                idBldgOX0.setXData(tvs, "OX");
            }
            else if (strOption == "MADE")
            {
                idBldgOX0 = idLWPline_LIM.copy("OX-AREAS-BLDG");                 //limit of building footprint already made

                idBldgOX0.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

                idBldgOX0.checkIfClosed();

                if (!idBldgOX0.isRightHand())
                {
                    idBldgOX0.reversePolyX();
                }
                idBldgOX0.setXData(tvs, "OX");
            }
            //BLDGOX1
            color = Misc.getColorByBlock(1);
            ObjectId idBldgOX1 = idBldgOX0.offset(EW_Pub.OX_LIMIT_H);               //BldgOX1 2dPolyline

            idBldgOX1.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

            //BLDGOX2
            color = Misc.getColorByBlock(2);
            ObjectId idBldgOX2 = idBldgOX0.offset(EW_Pub.OX_LIMIT_H + 2);            //BldgOX2 2dPolyline

            idBldgOX2.changeProp(color, "OX-LIM-OUTER", LineWeight.LineWeight020);

            SelectionSet objSSet      = EW_Utility1.buildSSetGradingLim();          //GRADING LIMIT
            ObjectId     idGradingLim = objSSet.GetObjectIds()[0];
            int          intSide      = 0;

            if (idBldgOX1.isOutsideGradingLimit(idGradingLim))
            {
                if (!idGradingLim.isRightHand())
                {
                    intSide = 1;
                }
                else
                {
                    intSide = -1;
                }

                ObjectId idGradingLimOffset = idGradingLim.offset(0.2 * intSide);
                color = Misc.getColorByBlock(4);
                idGradingLimOffset.changeProp(LineWeight.LineWeight020, color);

                idBldgOX1 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX1, idGradingLimOffset);
                //modified OX1 - portion was outside GRADING LIMIT

                color = Misc.getColorByBlock(1);
                idBldgOX1.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

                tvs[2] = new TypedValue(1000, "OX1");
                idBldgOX1.setXData(tvs, "OX");

                idGradingLimOffset = idGradingLim.offset(0.1 * intSide);
                color = Misc.getColorByBlock(5);
                idGradingLimOffset.changeProp(LineWeight.LineWeight020, color);

                idBldgOX2 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX2, idGradingLimOffset);
                //modified OX2 - portion was outside GRADING LIMIT
                color = Misc.getColorByBlock(2);
                idBldgOX2.changeProp(color, "OX-LIM-OUTER", LineWeight.LineWeight020);

                tvs[2] = new TypedValue(1000, "OX2");
                idBldgOX2.setXData(tvs, "OX");
            }
            else if (idBldgOX2.isOutsideGradingLimit(idGradingLim))
            {
                if (!idGradingLim.isRightHand())
                {
                    intSide = 1;
                }
                else
                {
                    intSide = -1;
                }

                ObjectId idGradingLimOffset = idGradingLim.offset(0.1 * intSide);
                color = Misc.getColorByBlock(4);
                idGradingLimOffset.changeProp(LineWeight.LineWeight020, color);

                idBldgOX2 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX2, idGradingLimOffset);
                //modified OX2 - portion was outside GRADING LIMIT
                color = Misc.getColorByBlock(1);
                idBldgOX2.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

                tvs[2] = new TypedValue(1000, "OX1");
                idBldgOX1.setXData(tvs, "OX");

                tvs[2] = new TypedValue(1000, "OX2");
                idBldgOX2.setXData(tvs, "OX");
            }
            else
            {
                tvs[2] = new TypedValue(1000, "OX1");
                idBldgOX1.setXData(tvs, "OX");

                tvs[2] = new TypedValue(1000, "OX2");
                idBldgOX2.setXData(tvs, "OX");
            }

            //BLDGOX3
            ObjectId idBldgOX3 = ObjectId.Null;

            if (strOption == "MAKE")
            {
                ObjectId idBldgOXT = getOX_PadLim(idLWPline_LIM, idBldgOX0);
                //building footprint and outer limit of building footprint
                idBldgOX3 = idBldgOXT.offset(-EW_Pub.FOOTING_LIMIT_IN_H);
                color     = Misc.getColorByBlock(3);
                idBldgOX3.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);
                idBldgOXT.delete();

                tvs[2] = new TypedValue(1000, "OX3");
                idBldgOX3.setXData(tvs, "OX");
            }
            else if (strOption == "MADE")
            {
                idBldgOX3 = idBldgOX0.offset(-EW_Pub.FOOTING_LIMIT_IN_H);
                color     = Misc.getColorByBlock(3);
                idBldgOX3.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

                tvs[2] = new TypedValue(1000, "OX3");
                idBldgOX3.setXData(tvs, "OX");
            }

            //BLDGOX4
            ObjectId idBldgOX4 = idBldgOX3.offset(-2);

            //BldgOX4 2dPolyline
            color = Misc.getColorByBlock(4);
            idBldgOX4.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020);

            tvs[2] = new TypedValue(1000, "OX4");
            idBldgOX4.setXData(tvs, "OX");
            ObjectId idLine = ObjectId.Null;

            Handle  h2d, h3d;
            double  dblSlope, dblAngBase, dblAngTest;
            Point3d pnt3dCEN = Pub.pnt3dO, pnt3dTAR = Pub.pnt3dO, pnt3dX = Pub.pnt3dO;

            ObjectId idDict = Dict.getNamedDictionary("GRADEDOCK", out exists);

            if (!exists)
            {
                Point3d varPntCen = idLWPline_LIM.getCentroid();
                //  objLWPline_LIM.getXdata "BldgSlab", varXDataType, varXData
                //
                //  Dim objBldgSlab As Polyline
                //  Set objBldgSlab = clsdwg.thisdrawing.HandleToObject(varXData(1))
                //  Dim varPntsLWPline As Variant
                //  varPntsLWPline = objBldgSlab.getCoordinates3d
                //  Dim varPnts3dPoly As Variant
                //  varPnts3dPoly = convert2dCoordsTo3dCoords(varPntsLWPline)
                //
                //
                //  Dim varVector As Vector
                //  varVector = getClosetAdjacentSegment(dPntCen, objBldgSlab)
                //  MsgBox ("Direction to nearest segment is: " & varVector.Dir & _
                //'           vbCr & _
                //'           "Distance to nearest segment is: " & varVector.Dist)
                //
                //  If isInside(varPntCen, varPnts3dPoly) = False Then
                //    MsgBox "Calculated centroid location is outside limits of Building footprint"
                //    Exit Function
                //  End If

                double elevCen = surf.FindElevationAtXY(varPntCen.X, varPntCen.Y);
                //SURFACE = "CPNT-ON"
                double dblAngTar = 0; int intMark = 0;

                Geom.getEastWestBaseLineDir(idLWPline_LIM, ref dblAngTar, ref intMark);

                Point3d dPntTAR = varPntCen.traverse(dblAngTar, 20);
                double  elevTar = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y);
                dblSlope = System.Math.Round((elevTar - varPntCen.Z) / 20, 4);

                if (dblSlope == 0)
                {
                    dPntTAR  = varPntCen.traverse(dblAngTar + pi / 2, 20);
                    elevTar  = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y);
                    dblSlope = System.Math.Round((elevTar - varPntCen.Z) / 20, 4);


                    if (System.Math.Round(dblSlope, 3) == 0)
                    {
                        dPntTAR = varPntCen.traverse(dblAngTar - pi / 2, 20);                         //back to original orientation
                        elevTar = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y);
                    }
                }
                else if (dblSlope < 0)
                {
                    dblAngTar = dblAngTar + pi;
                }

                dblAngBase = varPntCen.getDirection(dPntTAR);

                idLine = Draw.addLine(varPntCen, dPntTAR);

                EW_Dict.updateDictGRADEDOCK(idLWPline_LIM.getHandle(), "0".stringToHandle(), dblSlope, varPntCen, dPntTAR);                 //obj3dPoly.handle not pertinent at earthwork stage
            }
            else
            {
                EW_Dict.retrieveDictGRADEDOCK(out h2d, out h3d, out dblSlope, out pnt3dCEN, out pnt3dTAR);

                dblAngBase = pnt3dCEN.getDirection(pnt3dTAR);
                double dblLenBase = pnt3dCEN.getDistance(pnt3dTAR);

                Point3d varPntPolar = pnt3dCEN.traverse(dblAngBase, dblLenBase);
                idLine = Draw.addLine(pnt3dCEN, varPntPolar);
            }

            List <Point3d> varPntInt = idLine.intersectWith(idBldgOX0, extend.source);

            if (varPntInt.Count > 0)
            {
                for (int i = 0; i < varPntInt.Count; i++)
                {
                    pnt3dX     = varPntInt[i];
                    dblAngTest = pnt3dCEN.getDirection(pnt3dX);


                    if (System.Math.Round(dblAngTest, 4) == System.Math.Round(dblAngBase, 4))
                    {
                        idLine   = Draw.addLine(pnt3dCEN, pnt3dX);
                        pnt3dTAR = new Point3d(pnt3dX.X, pnt3dX.Y, pnt3dCEN.Z + pnt3dCEN.getDistance(pnt3dTAR) * dblSlope);
                    }
                }
            }

            double elev = surf.FindElevationAtXY(pnt3dCEN.X, pnt3dCEN.Y);

            pnt3dCEN = new Point3d(pnt3dCEN.X, pnt3dCEN.Y, elev);

            double dblOffOX = EW_Pub.OUTER_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX");

            color = Misc.getColorByLayer();
            //OX1
            ObjectId id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX1, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX1", dblOffOX, 20);

            id3dPoly.changeProp(LineWeight.LineWeight050, color);

            varPntInt = idLine.intersectWith(idBldgOX2, extend.source);
            idLine.delete();


            if (varPntInt.Count > 2)
            {
                for (int i = 0; i < varPntInt.Count; i++)
                {
                    pnt3dX     = varPntInt[i];
                    dblAngTest = pnt3dCEN.getDirection(pnt3dX);

                    if (System.Math.Round(dblAngTest, 4) == System.Math.Round(dblAngBase, 4))
                    {
                        idLine = Draw.addLine(pnt3dCEN, pnt3dX);

                        pnt3dTAR = pnt3dTAR.addElevation(pnt3dCEN.Z + pnt3dCEN.getDistance(pnt3dX) * dblSlope);
                        idLine.delete();
                        break;
                    }
                }
            }

            dblOffOX = EW_Pub.OUTER_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX");

            //OX3
            id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX3, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX3", dblOffOX);
            id3dPoly.changeProp(LineWeight.LineWeight050, color);

            dblOffOX = EW_Pub.COLUMN_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX");

            //OX4
            id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX4, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX4", dblOffOX);
            id3dPoly.changeProp(LineWeight.LineWeight050, color);

            Point3dCollection pnts3d = idBldgOX0.poly_pnt3dColl();

            objSSet = EW_Utility1.buildSSet17(pnts3d);             //get K BRACE areas

            ObjectId[] ids = objSSet.GetObjectIds();

            color = Misc.getColorByBlock(7);
            //BEGIN K BRACE
            for (int i = 0; i < ids.Length; i++)
            {
                ObjectId idBrace = ids[i];
                idBrace = idBrace.offset(5.0);
                idBrace.changeProp(LineWeight.LineWeight030, color);

                dblOffOX = EW_Pub.K_BRACE_V + EW_Utility1.getDepth(strLayer, "OX");

                id3dPoly = EW_Build3dPoly.build3dPoly(idBrace, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OTHER", dblOffOX);
                id3dPoly.changeProp(color, "OX-BRKLINE");
                //bottom of K-Brace overexcavation

                dblOffOX = EW_Pub.COLUMN_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX");
                color    = Misc.getColorByBlock(5);
                idBrace  = idBrace.offset(0.2);
                idBrace.changeProp(color);

                List <Point3d> pnts3dBrace = idBrace.getCoordinates3dList();
                List <Point3d> pnts3dNew   = new List <Point3d>();

                for (int j = 0; j < pnts3dBrace.Count; j++)
                {
                    Point3d pnt3dBEG = pnts3dBrace[i + 0];
                    Point3d pnt3dEND = pnts3dBrace[i + 1];

                    double dblAng = pnt3dBEG.getDirection(pnt3dEND);
                    //angle of each segment

                    double angDiff = System.Math.Round(dblAngBase - dblAng, 2);

                    if (angDiff == 0)
                    {
                        pnt3dX = pnt3dBEG.traverse(dblAng - pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0);
                        pnts3dNew.Add(pnt3dX);
                    }
                    else if (angDiff == System.Math.Round(pi / 2, 2) || angDiff == System.Math.Round(3 * pi / 2, 2))
                    {
                        pnt3dX = pnt3dBEG.traverse(dblAng + pi, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0);
                        pnts3dNew.Add(pnt3dX);
                    }
                    else if (angDiff == System.Math.Round(-1 * pi / 2, 2) || angDiff == System.Math.Round(-3 * pi / 2, 2))
                    {
                        pnt3dX = pnt3dBEG.traverse(dblAng - pi, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0);
                        pnts3dNew.Add(pnt3dX);
                    }
                    else if (angDiff == System.Math.Round(1 * pi, 2) || angDiff == System.Math.Round(3 * pi, 2))
                    {
                        pnt3dX = pnt3dBEG.traverse(dblAng + pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0);
                        pnts3dNew.Add(pnt3dX);
                    }
                    else if (angDiff == System.Math.Round(-1 * pi, 2) || angDiff == System.Math.Round(-3 * pi, 2))
                    {
                        pnt3dX = pnt3dBEG.traverse(dblAng - pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0);
                        pnts3dNew.Add(pnt3dX);
                    }

                    //Call addCircle(dPntPolar, 2, 1)
                }

                pnts3dNew.Add(pnts3dNew[0]);
                ObjectId idPoly = Draw.addPoly(pnts3dNew);
                idPoly.checkIfClosed3d();

                id3dPoly = EW_Build3dPoly.build3dPoly(id3dPoly, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OTHER", dblOffOX);
                id3dPoly.changeProp(color, "OX-BRKLINE");

                idPoly.delete();
            }

            //END K BRACE

            return(idBldgOX2);
        }
Пример #20
0
        modAdjacentAreas_Subtract(ObjectId idBldgOX2, bool boolFirstPass)
        {
            if (pub.boolDebug)
            {
                BaseObjs.write("Select _XX- Area");
                objSSet = EW_Utility1.buildSSet20();   //select on screen

                boolFirstPass = true;
            }
            else
            {
                if (boolFirstPass)
                {
                    objSSet = EW_Utility1.buildSSet0();                                //get _XX-*
                }
                else
                {
                    objSSet = EW_Utility1.buildSSet19();                                //get OX-AREAS-2d - select all
                }
            }

            ObjectId[] ids = objSSet.GetObjectIds();

            ObjectId idAreaCopy = ObjectId.Null;

            List <ObjectId> idsElemOX2  = new List <ObjectId>();
            List <ObjectId> idsElemArea = new List <ObjectId>();

            for (int i = 0; i < ids.Length; i++)
            {
                ObjectId id = ids[i];

                Polyline objArea = (Polyline)id.getEnt();
                objArea.checkIfClosed();

                string strLayer = objArea.Layer;

                switch (strLayer)
                {
                case "_XX-FLOOR SLAB_A":
                case "_XX-FLOOR SLAB_B":
                case "_XX-FLOOR SLAB_C":
                case "_XX-OFFICE SLAB AND SAND":
                    //, "_XX-BUILDING ADJACENT LANDSCAPING"

                    break;

                default:

                    if (boolFirstPass)
                    {
                        idAreaCopy = Conv.processBndry(objArea.copy());
                        idAreaCopy.changeProp(clr.byl, "OX-AREAS-2d");
                    }
                    else
                    {
                        idAreaCopy = id;
                    }

                    if (pub.boolDebug)
                    {
                        idAreaCopy.changeProp(LineWeight.LineWeight050, clr.yel);
                    }

                    List <Point3d> varPntsInt = idBldgOX2.intersectWith(idAreaCopy, extend.none);

                    if (varPntsInt.Count == 0)
                    {
                        TypedValue[] tvs = new TypedValue[2] {
                            new TypedValue(1001, "OX-Layer"),
                            new TypedValue(1000, strLayer)
                        };

                        idAreaCopy.setXData(tvs, "OX-Layer");
                    }
                    else
                    {
                        idsElemOX2.Add(idBldgOX2);

                        ObjectId idRegionOX2 = idBldgOX2.addRegion();
                        idRegionOX2.changeProp(LineWeight.LineWeight050, clr.c180);
                        idAreaCopy.checkIfClosed();
                        idAreaCopy.changeProp(LineWeight.LineWeight200, clr.cyn);

                        ObjectId idRegionArea = idAreaCopy.addRegion();
                        idRegionArea.changeProp(LineWeight.LineWeight050, clr.blu);

                        Region objRegionOX2  = (Region)idBldgOX2.getEnt();
                        Region objRegionArea = (Region)idRegionArea.getEnt();

                        objRegionArea.BooleanOperation(BooleanOperationType.BoolSubtract, objRegionOX2);

                        if (objRegionArea.Area > 0)
                        {
                            DBObjectCollection varExplodeObjs = new DBObjectCollection();
                            objRegionArea.Explode(varExplodeObjs);

                            Entity objEnt = (Entity)varExplodeObjs[0];

                            if (objEnt is Region)
                            {
                                idRegionArea.delete();

                                for (int j = 0; j < varExplodeObjs.Count; j++)
                                {
                                    Region             objRegion = (Region)varExplodeObjs[j];
                                    DBObjectCollection varEnts   = new DBObjectCollection();
                                    objRegion.Explode(varEnts);
                                    objRegion.ObjectId.delete();
                                    idAreaCopy = varEnts.rebuildPoly();
                                    idAreaCopy.changeProp(clr.byl, "OX-AREAS-2d");

                                    TypedValue[] tvs = new TypedValue[3] {
                                        new TypedValue(1001, "OX-Layer"),
                                        new TypedValue(1000, strLayer),
                                        new TypedValue(1000, "remaining after subtraction of OX")
                                    };

                                    idAreaCopy.setXData(tvs, "OX-Layer");
                                }
                            }
                            else
                            {
                                idRegionArea.delete();
                                idAreaCopy = varExplodeObjs.rebuildPoly();
                                idAreaCopy.changeProp(clr.byl, "OX-AREAS-2d");

                                TypedValue[] tvs = new TypedValue[3] {
                                    new TypedValue(1001, "OX-Layer"),
                                    new TypedValue(1000, strLayer),
                                    new TypedValue(1000, "remaining after subtraction of OX")
                                };

                                idAreaCopy.setXData(tvs, "OX-Layer");
                            }
                        }
                        else
                        {
                        }
                    }
                    break;
                }
            }
            return;
        }
Пример #21
0
        setupSpreadSheetMS(double dblVolCut = 0, double dblVolFill = 0)
        {
            bool boolIsOpen = false;

            if (dblVolFill == 0)
            {
                bool     exists;
                ObjectId idSurfaceCUT  = Surf.getSurface("VOL_EXIST_BOT", out exists);
                ObjectId idSurfaceFILL = Surf.getSurface("VOL_BOT_SG", out exists);

                TinVolumeSurface objSurfaceFILL = (TinVolumeSurface)idSurfaceFILL.getEnt();
                TinVolumeSurface objSurfaceCUT  = (TinVolumeSurface)idSurfaceCUT.getEnt();

                dblVolCut  = objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27;
                dblVolCut  = dblVolCut + objSurfaceCUT.GetVolumeProperties().UnadjustedCutVolume / 27;
                dblVolFill = dblVolFill + objSurfaceCUT.GetVolumeProperties().UnadjustedFillVolume / 27;
            }

            string strPath     = BaseObjs.docFullName;
            string strJN       = BaseObjs.jobNumber();
            string strFN       = string.Format("{0}EW.xlsx", strJN);
            string strFullPath = strPath + "\\" + strFN;

            SelectionSet objSSet = EW_Utility1.buildSSet8();

            objSSet.eraseSelectedItems();

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

            Point3d varPntIns = objTable.Position;

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

            double dblPntX = varPntIns.X + dblWidth + 10;
            double dblPntY = varPntIns.Y - 8;

            string strPntX = System.Math.Round(dblPntX, 2).ToString();
            string strPntY = System.Math.Round(dblPntY, 2).ToString();

            string strPntIns = string.Format("{0},{1}", strPntX, strPntY);

            Excel._Application objExcelApp = (Excel._Application)Microsoft.VisualBasic.Interaction.GetObject(null, "Excel.Application");
            Excel.Workbook     objWB       = null;
            Excel_ext          excl        = null;

            if (objExcelApp == null)
            {
                excl        = new Excel_ext();
                objExcelApp = excl.excelAPP;
            }
            else
            {
                for (int i = 1; i < objExcelApp.Workbooks.Count; i++)
                {
                    objWB = objExcelApp.Workbooks[i];
                    if (objWB.Name == strFN)
                    {
                        boolIsOpen = true;
                        break;
                    }
                }
            }

            objExcelApp.Visible = true;


            if (!boolIsOpen)
            {
                if (FileSystem.FileExists(strFullPath))
                {
                    objWB = objExcelApp.Workbooks.Open(strFullPath);
                }
                else
                {
                    FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath);
                    objWB = objExcelApp.Workbooks.Open(strFullPath);
                    string mess = string.Format("{0} not found.  A copy of the template has been created in {1}\nExiting...", strFN, strPath);
                    MessageBox.Show(mess);
                }
            }

            Excel.Worksheet objWS = objWB.Worksheets["SUMMARY"];
            objWS.Activate();
            objWS.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible;

            objWS.Range["SUMMARY!volCUT"].Value     = dblVolCut;
            objWS.Range["SUMMARY!volFILL"].Value    = dblVolFill;
            objWS.Range["SUMMARY!JOB_NUMBER"].Value = BaseObjs.docName.Substring(1, 4);
            objWS.Range["EW_SUMMARY"].Copy();
            objExcelApp.Visible = true;

            BaseObjs._editor.Regen();

            BaseObjs._acadDoc.SendStringToExecute(string.Format("_pasteclip {0}\r", strPntIns), true, false, false);

            objSSet = EW_Utility1.buildSSet8();

            Autodesk.AutoCAD.DatabaseServices.Ole2Frame objAcadOle = null;
            if (objSSet == null || objSSet.Count == 0)
            {
                SelectionSet ss = BaseObjs._editor.SelectAll().Value;
                int          k  = ss.Count;
                ObjectId     id = ss.GetObjectIds()[k - 1];
                using (var tr = BaseObjs.startTransactionDb())
                {
                    objAcadOle            = (Ole2Frame)tr.GetObject(id, OpenMode.ForWrite);
                    objAcadOle.LockAspect = false;
                    objAcadOle.WcsHeight  = dblHeight;
                    objAcadOle.WcsWidth   = dblHeight / 2;
                    objAcadOle.Layer      = "ZZ_ZZ-SPREADSHEET";
                    tr.Commit();
                }
            }
            else
            {
                using (var tr = BaseObjs.startTransactionDb()){
                    objAcadOle            = (Ole2Frame)tr.GetObject(objSSet.GetObjectIds()[0], OpenMode.ForWrite);
                    objAcadOle.LockAspect = false;
                    objAcadOle.WcsHeight  = dblHeight;
                    objAcadOle.WcsWidth   = dblHeight / 2;
                    objAcadOle.Layer      = "ZZ_ZZ-SPREADSHEET";
                }
            }

            BaseObjs.acadActivate();
        }