Exemplo n.º 1
0
        getExGround(TinSurface objSurfaceEXIST, Alignment objAlignRF, double dblStationRF, double[] dblOffsets)
        {
            EXGROUND vExGround = null;

            double        dblEasting  = 0;
            double        dblNorthing = 0;
            List <double> dblElev     = null;

            for (int i = 0; i < dblOffsets.Length; i++)
            {
                objAlignRF.PointLocation(dblStationRF, dblOffsets[i], ref dblEasting, ref dblNorthing);
                dblElev[i] = objSurfaceEXIST.FindElevationAtXY(dblEasting, dblNorthing);
            }

            vExGround.RF.Offset = (float)dblOffsets[0];
            vExGround.RF.Elev   = (float)dblElev[0];

            vExGround.TC.Offset = (float)dblOffsets[1];
            vExGround.TC.Elev   = (float)dblElev[1];

            vExGround.TOE.Offset = (float)dblOffsets[2];
            vExGround.TOE.Elev   = (float)dblElev[2];

            vExGround.TOP.Offset = (float)dblOffsets[3];
            vExGround.TOP.Elev   = (float)dblElev[3];

            vExGround.PL.Offset = (float)dblOffsets[4];
            vExGround.PL.Elev   = (float)dblElev[4];

            vExGround.Off5.Offset = (float)dblOffsets[5];
            vExGround.Off5.Elev   = (float)dblElev[5];

            return(vExGround);
        }
Exemplo n.º 2
0
        getSurfaceElevation(ObjectId idAlign, double dblStation)
        {
            double     dblEasting = 0, dblNorthing = 0;
            TinSurface objSurface = fStake.SurfaceCPNT;

            idAlign.getAlignPointLoc(dblStation, 0.0, ref dblEasting, ref dblNorthing);
            return(objSurface.FindElevationAtXY(dblEasting, dblNorthing));
        }
 public double FindElevationAtXY(double x, double y)
 {
     try {
         double elevation = _surface.FindElevationAtXY(x, y);
         return(elevation);
     } catch (Autodesk.Civil.PointNotOnEntityException ex) {
         throw (new PointNotOnSurfaceException(ex.Message));
     }
 }
Exemplo n.º 4
0
        public static void processPoints(SelectionSet objSSet, List <Point3d> varPntsLeader)
        {
            winPadCerts wPadCerts = PC_Forms.pcForm.wPadCerts;

            int           k  = varPntsLeader.Count;
            List <double> dx = new List <double>();
            List <double> dy = new List <double>();

            for (int i = 1; i < k; i++)
            {
                dx.Add(varPntsLeader[i].X - varPntsLeader[i - 1].X);
                dy.Add(varPntsLeader[i].Y - varPntsLeader[i - 1].Y);
            }

            double dblDir = varPntsLeader[k - 2].getDirection(varPntsLeader[k - 1]);

            string strName = System.Convert.ToString(wPadCerts.lbxSurfaceName.SelectedItem);

            TinSurface objSurface = Surf.getTinSurface(strName);

            ObjectId[] ids = objSSet.GetObjectIds();

            for (int i = 0; i < ids.Length; i++)
            {
                List <Point3d> pnts3dLdr = new List <Point3d>();
                Point3d        pnt3d     = ids[i].getCogoPntCoordinates();

                double dblElevPnt = pnt3d.Z;
                pnts3dLdr.Add(new Point3d(pnt3d.X, pnt3d.Y, 0));

                for (int j = 0; j < dx.Count; j++)
                {
                    pnt3d = new Point3d(pnt3d.X + dx[j], pnt3d.Y + dy[j], 0);
                    pnts3dLdr.Add(pnt3d);
                }

                Point3d pnt3dInsTxt = pnt3d;

                double dblElevSurface = objSurface.FindElevationAtXY(pnts3dLdr[0].X, pnts3dLdr[0].Y);

                if (wPadCerts.optBase.IsChecked == true)
                {
                    dblElevSurface = dblElevSurface + (System.Convert.ToDouble(wPadCerts.tbxPvmtThickness.Text)) / 12;
                }
                else if (wPadCerts.optSG.IsChecked == true)
                {
                    dblElevSurface = dblElevSurface + (System.Convert.ToDouble(wPadCerts.tbxTotalSection.Text)) / 12;
                }

                PacCerts.PC_LblElevDiff.labelElevDiff(dblElevPnt, dblElevSurface, pnts3dLdr, pnt3dInsTxt, dblDir);
            }
        }
Exemplo n.º 5
0
        public void GetSurfaceData(string surfaceName)
        {
            ObjectIdCollection SurfaceIds = CivilDoc.GetSurfaceIds();

            foreach (ObjectId surfaceId in SurfaceIds)
            {
                TinSurface oSurface = surfaceId.GetObject(OpenMode.ForRead) as TinSurface;
                if (oSurface.Name == surfaceName)
                {
                    //Get surface parameters at the insert point
                    ZOnSurface = (float)oSurface.FindElevationAtXY(X0, Y0);
                    float direction = (float)oSurface.FindDirectionAtXY(X0, Y0);
                    float slope     = (float)oSurface.FindSlopeAtXY(X0, Y0);

                    //Get point coordinates for the second point of the vector
                    GetPointCoordinatesByRad(direction);
                    Z1 = (float)oSurface.FindElevationAtXY(X1, Y1);

                    Slope = (float)Math.Atan(slope);
                }
            }
        }
Exemplo n.º 6
0
        getSurfaceElevations(ObjectId idAlign, ref List <POI> varpoi)
        {
            double     dblEasting = 0, dblNorthing = 0;
            TinSurface objSurface = fStake.SurfaceCPNT;
            POI        vpoi;

            for (int i = 0; i < varpoi.Count; i++)
            {
                vpoi = varpoi[i];
                idAlign.getAlignPointLoc(varpoi[i].Station, 0.0, ref dblEasting, ref dblNorthing);
                vpoi.Elevation = objSurface.FindElevationAtXY(dblEasting, dblNorthing);
                varpoi[i]      = vpoi;
            }
        }
Exemplo n.º 7
0
        makeBotSurfaceGrid(int intInterval, int i1)
        {
            App.SetSystemVariable("PDSISE", 0.01);

            setPointStyleBOT();
            setPointLabelStyleBOT();
            bool       exists;
            TinSurface objSurfaceCPNT_ON = Surf.getTinSurface("CPNT-ON", out exists);

            Object[] varLimits = EW_Utility2.getLimits(intInterval);

            double dblPntXmin = (double)varLimits[0];
            double dblPntYmin = (double)varLimits[1];

            int iMax = (int)varLimits[2];
            int jMax = (int)varLimits[3];


            for (int j = 0; j <= jMax; j++)
            {
                double dblY = dblPntYmin + (j * intInterval);


                for (int i = 0; i <= iMax; i++)
                {
                    double dblX = dblPntXmin + (i * intInterval);

                    double dblZ_OX = objSurfaceCPNT_ON.FindElevationAtXY(dblX, dblY);


                    if (dblZ_OX > 0)    //point is inside OX boundary
                    {
                        Point3d  dblPnt     = new Point3d(dblX, dblY, dblZ_OX);
                        ObjectId idCivilPnt = dblPnt.setPoint("GRID-POINTS");
                    }
                }
            }

            TypedValue[] tvs = new TypedValue[4] {
                new TypedValue(1001, "BOT"),
                new TypedValue(1040, varLimits[0]),
                new TypedValue(1040, varLimits[1]),
                new TypedValue(1070, intInterval)
            };
            ObjectId idDictBOT = Dict.getNamedDictionary("BOT", out exists);

            idDictBOT.setXData(tvs, "BOT");

            return(varLimits);
        }
Exemplo n.º 8
0
        getSurfaceElev(double dblX, double dblY, TinSurface objSurface)
        {
            double dblElev = 0;
            double dblXX   = 0;
            double dblYY   = 0;

            dblElev = objSurface.FindElevationAtXY(dblX, dblY);

            if (dblElev > 0)
            {
                dblXX   = Math.roundDown2(dblX);
                dblYY   = Math.roundDown2(dblY);
                dblElev = objSurface.FindElevationAtXY(dblXX, dblYY);
            }

            if (dblElev < 0)
            {
                dblXX   = Math.roundUP2(dblX);
                dblYY   = Math.roundUP2(dblY);
                dblElev = objSurface.FindElevationAtXY(dblXX, dblYY);
            }

            return(dblElev);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        stakeMISC(string strCommand)
        {
            TinSurface objSurface = fStake.SurfaceCPNT;

            string       strLayer = fMisc.tbxLayer.Text;
            string       strDesc  = fMisc.tbxDesc0.Text + fMisc.tbxDescription.Text;
            PromptStatus ps;
            bool         escape;

            switch (strCommand)
            {
            case "InLine_Center":

                BaseObjs.acadActivate();

                Point3d pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                Point3d pnt3dPick = UserInput.getPoint("\nSelect Directional Point(any XY location): ", pnt3dTar, out escape, out ps, osMode: 8);

                double  dblAngDir1 = pnt3dTar.getDirection(pnt3dPick);
                Point3d pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                double  dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                Point3d pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1 + PI, double.Parse(fMisc.cbxOffset.Text));

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "InLine_Direction":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                pnt3dPick = UserInput.getPoint("\nSelect Directional Point(any XY location): ", pnt3dTar, out escape, out ps, osMode: 8);

                dblAngDir1 = pnt3dTar.getDirection(pnt3dPick);

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                if (double.Parse(fMisc.cbxOffsetDir.Text) == 0)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Direction Offset is 0 - revise....exiting");
                    return;
                }

                pnt3dPolar = pnt3dTar.traverse(dblAngDir1, double.Parse(fMisc.cbxOffset.Text) + double.Parse(fMisc.cbxOffsetDir.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                strDesc = string.Format("{0}' O/S {1} @", double.Parse(fMisc.cbxOffset.Text) +
                                        double.Parse(fMisc.cbxOffsetDir.Text), fMisc.cbxObjType.Text);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "Proj2Curb":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);
                string xRefPath = "";
                Entity ent      = xRef.getEntity("\nSelect Adjacent Curb:", out escape, out xRefPath);

                Point3d pnt3dInt0 = getRadial_Perpendicular(pnt3dTar, ent);

                ent.ObjectId.delete();

                dblAngDir1 = pnt3dTar.getDirection(pnt3dInt0);

                pnt3dPolar = pnt3dInt0.traverse(dblAngDir1 + PI / 2, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dInt0.X, pnt3dInt0.Y);
                dblElev = dblElev + double.Parse(fMisc.cbxCurbHeight.Text) / 12;
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dInt0.traverse(dblAngDir1 - PI / 2, double.Parse(fMisc.cbxOffset.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);

                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "Proj2Bldg":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);
                Point3d pnt3dRef1 = UserInput.getPoint("Pick Point Perpendicular to Building: ", pnt3dTar, out escape, out ps, osMode: 8);
                dblAngDir1 = pnt3dTar.getDirection(pnt3dRef1);

                pnt3dPolar = pnt3dRef1.traverse(dblAngDir1 + PI / 2, double.Parse(fMisc.cbxOffset.Text));

                dblElev = objSurface.FindElevationAtXY(pnt3dRef1.X, pnt3dRef1.Y);
                pnt3d   = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                pnt3dPolar = pnt3dRef1.traverse(dblAngDir1 - PI / 2, double.Parse(fMisc.cbxOffset.Text));

                pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                break;

            case "AP":

                BaseObjs.acadActivate();

                pnt3dTar = UserInput.getPoint("\nSelect Target Point for Staking: ", out ps, osMode: 8);

                pnt3dRef1 = UserInput.getPoint("\nSelect Adjacent Angle Point1: ", out ps, osMode: 1);
                Point3d pnt3dRef2  = UserInput.getPoint("\nSelect Adjacent Angle Point2: ", out ps, osMode: 1);
                Point3d varPntPick = UserInput.getPoint("\nSelect Side: ", out ps, osMode: 0);

                double dblAngDelta = Geom.getAngle3Points(pnt3dRef1, pnt3dTar, pnt3dRef2);

                dblAngDir1 = pnt3dRef1.getDirection(pnt3dTar);
                double dblAngDir2 = pnt3dTar.getDirection(pnt3dRef2);

                bool isRightHand = (pnt3dTar.isRightSide(pnt3dRef1, pnt3dRef2)) ? true : false;

                pnt3dPolar = varPntPick.traverse(dblAngDir1 + PI / 2, 10);

                List <Point3d> pnts3d1 = new List <Point3d> {
                    pnt3dRef1, pnt3dTar
                };
                List <Point3d> pnts3d2 = new List <Point3d> {
                    varPntPick, pnt3dPolar
                };

                List <Point3d> pnts3dInt = pnts3d1.intersectWith(pnts3d2, false, extend.both);

                if (pnts3dInt.Count == 0)
                {
                    return;
                }
                bool boolHit = false, boolIN = false;
                int  intSide = 0;

                //PICK POINT ADJACENT TO FIRST SEGMENT
                if (pnt3dTar.isRightSide(pnt3dRef1, varPntPick))
                {
                    //CCW
                    if (isRightHand)
                    {
                        boolIN  = true;
                        intSide = -1;
                        //CW
                    }
                    else
                    {
                        boolIN  = false;
                        intSide = -1;
                    }
                    boolHit = true;
                }
                else
                {     //RIGHT SIDE OF FIRST SEGMENT
                    //CCW
                    if (isRightHand)
                    {
                        boolIN  = false;
                        intSide = 1;
                    }
                    else
                    {
                        boolIN = true;
                        //CW
                        intSide = 1;
                    }
                    boolHit = true;
                }

                if (!boolHit)
                {
                    pnt3dPolar = varPntPick.traverse(dblAngDir2 + PI / 2, 10);
                    pnts3d1    = new List <Point3d> {
                        pnt3dRef2, pnt3dTar
                    };
                    pnts3d2 = new List <Point3d> {
                        varPntPick, pnt3dPolar
                    };

                    List <Point3d> pnts3dInt2 = pnts3d1.intersectWith(pnts3d2, false, extend.both);

                    //PICK POINT ADJACENT TO SECOND SEGMENT

                    //LEFT SIDE OF SECOND SEGMENT
                    if (pnt3dRef2.isRightSide(pnt3dTar, varPntPick))
                    {
                        //CCW
                        if (isRightHand)
                        {
                            boolIN  = true;
                            intSide = -1;
                            //CW
                        }
                        else
                        {
                            boolIN  = false;
                            intSide = -1;
                        }
                        //RIGHT SIDE OF SECOND SEGMENT
                    }
                    else
                    {
                        //CCW
                        if (isRightHand)
                        {
                            boolIN  = false;
                            intSide = 1;
                            //CW
                        }
                        else
                        {
                            boolIN  = true;
                            intSide = 1;
                        }
                    }
                }

                if (boolIN)
                {
                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + dblAngDelta / 2 * intSide * -1, Convert.ToDouble(fMisc.cbxOffset.Text) / System.Math.Sin(dblAngDelta / 2));
                    dblElev    = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);
                    pnt3d      = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);
                }
                else
                {
                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + ((3 * PI / 2 - dblAngDelta) * intSide * -1), Convert.ToDouble((fMisc.cbxOffset).Text));
                    //point opposite begin point of next segment
                    dblElev = objSurface.FindElevationAtXY(pnt3dTar.X, pnt3dTar.Y);

                    pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);

                    pnt3dPolar = pnt3dTar.traverse(dblAngDir2 + (PI / 2 * intSide * -1), Convert.ToDouble((fMisc.cbxOffset).Text));
                    //point opposite begin point of next segment

                    pnt3d = new Point3d(pnt3dPolar.X, pnt3dPolar.Y, dblElev);
                    Stake_Calc.setOffsetPointMISC(pnt3d, strLayer, strDesc);
                }

                break;
            }
        }
Exemplo n.º 11
0
        setBldgElevRef(Alignment objAlign)
        {
            TinSurface objSurface = null;
            bool       exists     = false;

            try
            {
                objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                if (!exists)
                {
                    Stake_GetSurfaceCPNT.getSurfaceFromXRef("STAKE", "STAKE");
                    objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                }
            }
            catch (System.Exception)
            {
            }
            ObjectId idBldg = objAlign.GetPolyline();
            Point3d  pnt3d  = idBldg.getCentroid();

            Point3d pnt3dCen = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            if (pnt3dCen.Z == -99999.99)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Invalid Elevation at Reference Point - Exiting.......");
                return;
            }

            //Set objCircle = addcircle(pnt3dCEN, 3)
            //objCircle.color = acRed
            //objCircle.Update

            double dblAngTar = 0;
            int    intMark   = 0;

            idBldg.getEastWestBaseLineDir(ref dblAngTar, ref intMark);

            Point3d pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            double dblSlope = System.Math.Round((pnt3dTar.Z - pnt3dCen.Z) / 100, 4);

            //Set objCircle = addcircle(pnt3dTAR, 3)
            //objCircle.color = acYellow
            //objCircle.Update

            if (dblSlope == 0)
            {
                dblAngTar = dblAngTar + PI / 2;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3d    = pnt3dCen.traverse(dblAngTar, 100);
                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acGreen
                //   objCircle.Update

                if (System.Math.Round(dblSlope, 3) == 0)
                {
                    pnt3d = pnt3dCen.traverse(dblAngTar - PI / 2, 100);
                    //back to original orientation
                    pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                    //     Set objCircle = addcircle(pnt3dTAR, 3)
                    //     objCircle.color = acCyan
                    //     objCircle.Update
                }
            }
            else if (dblSlope < 0)
            {
                dblAngTar = dblAngTar + PI;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acBlue
                //   objCircle.Update

                dblSlope = -dblSlope;
            }

            BlockReference objBlkRef = null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                try
                {
                    List <string> attVals = new List <string> {
                        dblSlope.ToString()
                    };
                    objBlkRef       = Blocks.addBlockRef("G:\\TOOLBOX\\Slparrow_STAKE.dwg", pnt3dCen, dblAngTar, attVals);
                    objBlkRef.Layer = string.Format("STAKE-BLDG-{0}-LABEL", objAlign.Name);
                }
                catch (System.Exception)
                {
                }
                tr.Commit();
            }

            idBldg.delete();

            TypedValue[] tvs = new TypedValue[6] {
                new TypedValue(1001, "BLDG"),
                new TypedValue(1040, pnt3dCen.X),
                new TypedValue(1040, pnt3dCen.Y),
                new TypedValue(1040, pnt3dCen.Z),
                new TypedValue(1040, dblAngTar),
                new TypedValue(1040, dblSlope)
            };

            objAlign.ObjectId.setXData(tvs, "STAKE");
        }
Exemplo n.º 12
0
        RDR()
        {
            string prompt, result;
            bool   escape = false, exists = false, done = false, done2 = false;

            double trianglationFactor = 0.001;      //applied to treads to avoid vertical faces0

            double lenTread, lenLand, grdLandU, wthRiser;

            List <riserSum> rSum = new List <riserSum>();

            ResultBuffer rb;

            TypedValue[] tvs;
            Dict.deleteDictionary("RDR");
            ObjectId idDict = Dict.getNamedDictionary("RDR", out exists);

            if (exists)
            {
                rb       = Dict.getXRec(idDict, "Defaults");
                tvs      = rb.AsArray();
                lenTread = double.Parse(tvs[0].Value.ToString());
                lenLand  = double.Parse(tvs[1].Value.ToString());
                grdLandU = double.Parse(tvs[2].Value.ToString());
                wthRiser = double.Parse(tvs[4].Value.ToString());
            }
            else
            {
                lenTread = 11.0;
                lenLand  = 5.5;
                grdLandU = -0.01;
                wthRiser = 5.5;
            }

            do
            {
                prompt = string.Format("\nLength riser tread(LR): {0}; Width of Riser(W): {1}; Length upper landing(LL): {2}; Grade upper Landing(G): {3}; No Change <OK> [LR/W/LL/G/OK]", lenTread, wthRiser, lenLand, grdLandU);
                escape = UserInput.getUserInputKeyword("OK", out result, prompt, "LR W LL G OK");
                if (escape)
                {
                    return;
                }
                switch (result)
                {
                case "LR":
                    UserInput.getUserInput("Enter Riser trEAD LENGTH in Inches ", out lenTread, lenTread);
                    break;

                case "LL":
                    UserInput.getUserInput("Enter LENGTH of UPPER LANDING", out lenLand, lenLand);
                    break;

                case "G":
                    UserInput.getUserInput("Enter SLOPE of UPPER Landing from HIGH POINT towards LOW POINT: ", out grdLandU, grdLandU);
                    break;

                case "W":
                    UserInput.getUserInput("Enter RISER WIDTH: ", out wthRiser, wthRiser);
                    break;

                case "OK":
                    done = true;
                    break;
                }
            }while (!done);

            tvs = new TypedValue[5];
            tvs.SetValue(new TypedValue(1000, lenTread), 0);      //length of riser tread in inches
            tvs.SetValue(new TypedValue(1000, lenLand), 1);       //length of upper landing - perp to bldg
            tvs.SetValue(new TypedValue(1000, grdLandU), 2);      //grade of upper landing
            tvs.SetValue(new TypedValue(1000, wthRiser), 4);      //width of riser tread in inches
            Dict.addXRec(idDict, "Defaults", new ResultBuffer(tvs));

            object osMode = SnapMode.getOSnap();

            SnapMode.setOSnap((int)osModes.NON);
            TinSurface   surf = Surf.getTinSurface("CPNT-ON", out exists);
            Point3d      pnt3dPick;
            PromptStatus ps;
            Entity       ent = Select.selectEntity(typeof(Polyline3d), "\nSelect Building Floor Slab Breakline", "Selected entity was not a 3d Breakline", out pnt3dPick, out ps);

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

            Polyline3d poly3dFF = (Polyline3d)ent;      //Finish Floor breakline

            ent = Select.selectEntity(typeof(Polyline3d), "\nSelect Dock Apron Breakline adjacent to Building", "Selected entity was not a 3d Breakline", out pnt3dPick, out ps);
            if (ps != PromptStatus.OK)
            {
                return;
            }

            Polyline3d poly3dDK = (Polyline3d)ent;      //Dock brkline

            List <Point3d> pnts3dDK = poly3dDK.ObjectId.getCoordinates3dList();

            SnapMode.setOSnap((int)osModes.END);

            Point3d pnt3dR0 = UserInput.getPnt3d(Pub.pnt3dO, "\nSelect Riser connect point: upper RH corner of upper Landing: ", osMode: 1);
            Point3d pnt3dL0 = UserInput.getPnt3d(Pub.pnt3dO, "\nSelect Riser connect point: upper LH corner of upper Landing: ", osMode: 1);
            Point3d pnt3dR, pnt3dL;

            List <Point3d> pnts3dFF  = poly3dFF.ObjectId.getCoordinates3dList();
            List <Point3d> pnts3dSeg = new List <Point3d>();

            int x = 0;

            if (pnts3dFF.Count > 2)
            {
                x = Geom.getVertexNo(pnts3dFF, pnt3dR0);
                pnts3dSeg.Add(pnts3dFF[x]);
                pnts3dSeg.Add(pnts3dFF[x + 1]);
            }
            else
            {
                pnts3dSeg = pnts3dFF;
            }
            double dirSegFF = pnts3dSeg[0].getDirection(pnts3dSeg[1]);
            double dirRiser = pnt3dR0.getDirection(pnt3dL0);
            double dirPick  = 0.0;

            double  testRight = Geom.testRight(pnts3dSeg[0], pnts3dSeg[1], pnt3dR0);
            double  angle0    = 0.0;
            Point3d pnt3dTar  = Pub.pnt3dO;

            if (testRight > 0)
            {
                pnt3dTar = pnt3dR0.traverse(dirSegFF - pi / 2, 10.0);
                angle0   = dirSegFF + pi / 2;
            }
            else
            {
                pnt3dTar = pnt3dR0.traverse(dirSegFF + pi / 2, 10.0);
                angle0   = dirSegFF - pi / 2;
            }

            List <Point3d> pnts3dRay = new List <Point3d> {
                pnt3dR0,
                pnt3dTar
            };
            List <Point3d> pnts3dInt = pnts3dRay.intersectWith(pnts3dSeg, false, 0);
            Point3d        pnt3dRef  = Pub.pnt3dO;

            if (pnts3dInt.Count > 0)
            {
                pnt3dRef = pnts3dInt[0];
            }

            double slope      = (pnts3dSeg[1].Z - pnts3dSeg[0].Z) / pnts3dSeg[0].getDistance(pnts3dSeg[1]);
            double dirDiff    = System.Math.Round(dirSegFF - dirRiser, 3);
            double slopeRiser = 0.0;

            if (dirDiff == 0)
            {
                slopeRiser = slope;
            }
            else
            {
                slopeRiser = -slope;
            }

            double dist0    = pnts3dSeg[0].getDistance(pnt3dRef);
            double distTest = Geom.getPerpDistToLine(pnts3dSeg[0], pnts3dSeg[1], pnt3dR0);

            Vector3d v3d = new Vector3d(sMath.Cos(dirSegFF), sMath.Sin(dirSegFF), slope);

            Point3d  pnt3dRBase = pnt3dR0;
            Point3d  pnt3dRff, pnt3dLff;
            ObjectId idCgPnt     = ObjectId.Null;
            ObjectId idPoly3d    = ObjectId.Null;
            uint     pntNum      = 0;
            int      numRisers   = 1;
            double   distBetween = 0.0;

            bool single = false;

            prompt = "\nMode <Single/Multiple> [S/M]";
            result = string.Empty;
            escape = UserInput.getUserInputKeyword("S", out result, prompt, "S M");
            if (escape)
            {
                return;
            }
            switch (result)
            {
            case "S":
                numRisers = 1;
                single    = true;
                break;

            case "M":
                prompt = "\nUnEven or Even Spacing [U/E]";
                escape = UserInput.getUserInputKeyword("U", out result, prompt, "U E");
                if (escape)
                {
                    return;
                }
                switch (result)
                {
                case "E":
                    escape = UserInput.getUserInput("Enter # of risers to calculate: ", out result);
                    if (escape)
                    {
                        return;
                    }
                    numRisers = int.Parse(result.ToString());
                    escape    = UserInput.getUserInput("Enter Spacing: ", out result);
                    if (escape)
                    {
                        return;
                    }
                    distBetween = double.Parse(result.ToString());
                    Point3d pnt3dEnd = UserInput.getPoint("\nSelect upper RH corner of landing at next riser in direction of target risers:", out ps, osMode: 1);
                    if (pnt3dEnd == Pub.pnt3dO)
                    {
                        return;
                    }
                    double distX = pnt3dR0.getDistance(pnt3dEnd);

                    double diffX = sMath.Round(sMath.Abs(distX - distBetween), 3);
                    if (diffX > 0)
                    {
                        Application.ShowAlertDialog("Distance between picked points and Spacing does not agree.  Exiting...");
                        return;
                    }
                    dirPick = pnt3dR0.getDirection(pnt3dEnd);
                    break;

                case "U":
                    numRisers   = 1;
                    distBetween = 0.0;
                    dirPick     = 0.0;
                    break;
                }
                break;
            }

            int k = 0;

            do
            {
                done2 = single;

                for (int p = 0; p < numRisers; p++)
                {
                    double dist0X = 0;

                    if (distBetween != 0)
                    { //multiple risers  -  even spacing
                        pnt3dR0  = pnt3dRBase + v3d * p * distBetween;
                        dist0X   = dist0 + (p * distBetween);
                        pnt3dRff = pnts3dSeg[0] + v3d * dist0X;
                        if (p == numRisers - 1)
                        {
                            done2 = true;
                        }
                    }
                    else if (!single)
                    {     //multiple risers  -  uneven spacing
                        if (k == 0)
                        { //
                            pnt3dRff = pnts3dSeg[0].traverse(dirSegFF, dist0, slope);
                            dist0X   = dist0;
                            k++;
                        }
                        else
                        {
                            pnt3dR0 = UserInput.getPoint("Select upper RH corner of landing at next riser: ", out ps, osMode: 8);
                            if (pnt3dR0 == Pub.pnt3dO)
                            {
                                done2 = true;
                                break;
                            }
                            dist0X   = Geom.getPerpDistToLine(pnts3dSeg[0], pnts3dSeg[1], pnt3dR0);
                            pnt3dRff = pnts3dSeg[0].traverse(dirSegFF, dist0X, slope);
                        }
                    }
                    else
                    {
                        pnt3dRff = pnts3dSeg[0].traverse(dirSegFF, dist0, slope);     //single riser
                        dist0X   = dist0;
                    }

                    idCgPnt = pnt3dRff.setPoint(out pntNum, "CPNT-ON");

                    pnt3dLff = pnt3dRff.traverse(dirRiser, wthRiser, slopeRiser);
                    idCgPnt  = pnt3dLff.setPoint(out pntNum, "CPNT-ON");

                    double elev0 = pnts3dSeg[0].Z + slope * dist0X;

                    pnt3dR0  = new Point3d(pnt3dR0.X, pnt3dR0.Y, elev0 - 0.04);             //point at upper right side of upper landing
                    idPoly3d = Draw.addPoly3d(pnt3dRff, pnt3dR0, "CPNT-BRKLINE");

                    pnt3dL0  = pnt3dR0.traverse(dirRiser, wthRiser, slopeRiser);             //point at upper left side of upper landing
                    idPoly3d = Draw.addPoly3d(pnt3dLff, pnt3dL0, "CPNT-BRKLINE");
                    Point3dCollection pnts3dR = new Point3dCollection();
                    pnts3dR.Add(pnt3dR0);
                    idCgPnt = pnt3dR0.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0 + pi, -1);

                    Point3dCollection pnts3dL = new Point3dCollection();
                    pnts3dL.Add(pnt3dL0);
                    idCgPnt = pnt3dL0.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0 + pi, 1);

                    pnt3dR = pnt3dR0.traverse(angle0, lenLand - trianglationFactor, grdLandU);     //point at lower right side of upper landing
                    pnts3dR.Add(pnt3dR);
                    idCgPnt = pnt3dR.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, 1);

                    Point3d pnt3dBase = pnt3dR.traverse(angle0, trianglationFactor);

                    pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);                       //point at lower left side of upper landing
                    pnts3dL.Add(pnt3dL);
                    idCgPnt = pnt3dL.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, -1);

                    idPoly3d = Draw.addPoly3d(pnt3dR, pnt3dL, "CPNT-BRKLINE");

                    Dictionary <double, double> res = new Dictionary <double, double>();
                    done = false;
                    double dZ = 0.0, adj = 0.0, distX = 0.0, steps = 0.0, rem = 0.0, hgtRiser = 0.0;
                    int    stepX       = 0;
                    double elevSurface = 0.0;
                    double i           = 7.0;
                    do
                    {
                        pnt3dR      = new Point3d(pnt3dBase.X, pnt3dBase.Y, pnt3dBase.Z - i / 12.0); //bottom of first step for height - Base was adjusted for triangulationFactor
                        elevSurface = surf.FindElevationAtXY(pnt3dR.X, pnt3dR.Y);
                        dZ          = pnt3dR.Z - elevSurface;
                        if (dZ < i / 12)
                        {
                            break;
                        }

                        Vector3d v3dx   = new Vector3d(System.Math.Cos(angle0), System.Math.Sin(angle0), -i / lenTread);
                        Point3d  pnt3dX = surf.GetIntersectionPoint(pnt3dR, v3dx);

                        distX = pnt3dR.getDistance(pnt3dX);
                        steps = distX / (lenTread / 12);
                        rem   = System.Math.Truncate(steps) + 1 - steps;
                        res.Add(i, rem);
                        if (rem < 0.05)
                        {
                            stepX    = (int)System.Math.Truncate(steps) + 1;
                            adj      = rem * i / 12;
                            hgtRiser = i;
                            if (rem * i < stepX * 0.0625)
                            {
                                hgtRiser = i - 0.0625;
                                adj      = adj - stepX * 0.0625 / 12;
                            }
                            break;
                        }
                        if (i == 4)
                        {
                            done = true;
                        }
                        i = i - 0.0625;
                    }while (!done);


                    string dimV   = Conv.decimalToFraction(hgtRiser);
                    string topTxt = string.Format("({0}) {1}", stepX, dimV);
                    rSum.Add(new riserSum {
                        idPoly3d = idPoly3d, angle = angle0, lenLanding = lenLand, topText = topTxt
                    });

                    pnts3dR.Add(pnt3dR);
                    pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);
                    pnts3dL.Add(pnt3dL);

                    for (int n = 1; n < steps; n++)
                    {
                        pnt3dR = pnt3dR.traverse(angle0, lenTread / 12 - trianglationFactor);       //adjusted to avoid vertical faces
                        pnts3dR.Add(pnt3dR);

                        pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);
                        pnts3dL.Add(pnt3dL);

                        idPoly3d = Draw.addPoly3d(pnt3dR, pnt3dL, "CPNT-BRKLINE");

                        pnt3dR = pnt3dR.traverse(angle0, trianglationFactor);                       //get back to correct location
                        pnt3dR = new Point3d(pnt3dR.X, pnt3dR.Y, pnt3dR.Z - hgtRiser / 12);
                        pnts3dR.Add(pnt3dR);

                        pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);
                        pnts3dL.Add(pnt3dL);

                        idPoly3d = Draw.addPoly3d(pnt3dR, pnt3dL, "CPNT-BRKLINE");
                    }

                    pnt3dR = pnt3dR.traverse(angle0, lenTread / 12 - 0.005);  //shorten width of last tread to avoid vertical faces
                    pnts3dR.Add(pnt3dR);

                    pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);
                    pnts3dL.Add(pnt3dL);

                    idPoly3d = Draw.addPoly3d(pnt3dR, pnt3dL, "CPNT-BRKLINE");

                    pnt3dR = pnt3dR.traverse(angle0, 0.005);                //makeup for reduced width of tread
                    pnt3dR = new Point3d(pnt3dR.X, pnt3dR.Y, pnt3dR.Z - (hgtRiser / 12 - adj));
                    pnts3dR.Add(pnt3dR);
                    idCgPnt = pnt3dR.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, 1);

                    pnt3dL = pnt3dR.traverse(dirRiser, wthRiser, slopeRiser);
                    pnts3dL.Add(pnt3dL);
                    idCgPnt = pnt3dL.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, -1);


                    pnt3dR  = pnt3dR.traverse(angle0 + pi / 2, 0.5, slope);          //point at toe of stairs / outside face of sidewall
                    idCgPnt = pnt3dR.setPoint(out pntNum, "CPNT-ON");

                    pnt3dL  = pnt3dL.traverse(angle0 - pi / 2, 0.5, slopeRiser);        //point at toe of stairs / outside face of sidewall
                    idCgPnt = pnt3dL.setPoint(out pntNum, "CPNT-ON");

                    List <Point3d> pnts3dSegDK = new List <Point3d>();

                    if (pnts3dDK.Count > 2)
                    {
                        x = Geom.getVertexNo(pnts3dDK, pnt3dR);
                        pnts3dSegDK.Add(pnts3dDK[x]);
                        pnts3dSegDK.Add(pnts3dDK[x + 1]);
                    }
                    else
                    {
                        pnts3dSegDK = pnts3dDK;
                    }

                    double dirSegDK = pnts3dSegDK[0].getDirection(pnts3dSegDK[1]);
                    double slopeDK  = pnts3dSegDK[0].getSlope(pnts3dSegDK[1]);
                    double lenR     = Geom.getPerpDistToLine(pnts3dSegDK[0], pnts3dSegDK[1], pnt3dR);

                    Point3d pnt3dRint = pnts3dSegDK[0].traverse(dirSegDK, lenR, slopeDK);
                    idCgPnt = pnt3dRint.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, 1);

                    double  lenL      = Geom.getPerpDistToLine(pnts3dSegDK[0], pnts3dSegDK[1], pnt3dL);
                    Point3d pnt3dLint = pnts3dSegDK[0].traverse(dirSegDK, lenL, slopeDK);
                    idCgPnt = pnt3dLint.setPoint(out pntNum, "CPNT-ON");
                    addRiserCallout(idCgPnt, angle0, -1);

                    if (lenL > lenR)
                    {
                        pnts3dDK.Insert(x + 1, pnt3dRint);
                        pnts3dDK.Insert(x + 2, pnt3dR);
                        pnts3dDK.Insert(x + 3, pnt3dL);
                        pnts3dDK.Insert(x + 4, pnt3dLint);
                    }
                    else
                    {
                        pnts3dDK.Insert(x + 1, pnt3dLint);
                        pnts3dDK.Insert(x + 2, pnt3dL);
                        pnts3dDK.Insert(x + 3, pnt3dR);
                        pnts3dDK.Insert(x + 4, pnt3dRint);
                    }

                    ObjectId idPoly3dR = Draw.addPoly3d(pnts3dR, "CPNT-BRKLINE");
                    ObjectId idPoly3dL = Draw.addPoly3d(pnts3dL, "CPNT-BRKLINE");

                    tvs = new TypedValue[4];
                    tvs.SetValue(new TypedValue(1001, apps.lnkRiser), 0);
                    tvs.SetValue(new TypedValue(1000, "cmdRDR"), 1);
                    tvs.SetValue(new TypedValue(1000, "R"), 2);
                    tvs.SetValue(new TypedValue(1005, idPoly3dL.getHandle()), 3);
                    idPoly3dR.setXData(tvs, apps.lnkRiser);

                    tvs = new TypedValue[4];
                    tvs.SetValue(new TypedValue(1001, apps.lnkRiser), 0);
                    tvs.SetValue(new TypedValue(1000, "cmdRDR"), 1);
                    tvs.SetValue(new TypedValue(1000, "L"), 2);
                    tvs.SetValue(new TypedValue(1005, idPoly3dR.getHandle()), 3);
                    idPoly3dL.setXData(tvs, apps.lnkRiser);
                }
            }while (!done2);

            foreach (riserSum r in rSum)
            {
                Point3d pnt3dMid = r.idPoly3d.getBegPnt().getMidPoint2d(r.idPoly3d.getEndPnt());
                addRiserSummaryCallout(pnt3dMid, r.angle, r.lenLanding, r.topText);
            }

            Point3dCollection pnts3dDKc = new Point3dCollection();

            foreach (Point3d pnt3d in pnts3dDK)
            {
                pnts3dDKc.Add(pnt3d);
            }

            ObjectId idPoly3dDK = Draw.addPoly3d(pnts3dDKc, "CPNT-BRKLINE");

            poly3dDK.ObjectId.delete();

            SnapMode.setOSnap((int)osMode);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Get elevation from %surfaceName% along %alignmentName% at pk and offset 
 /// </summary>
 /// <param name="alignmentName">Name of the alignment</param>
 /// <param name="surfaceName">Name of the surface</param>
 /// <param name="pk">PK position along alignment</param>
 /// <param name="offset">Offset distance from alignment</param>
 /// <param name="elevation">out parametr - elevation at this point</param>
 /// <returns>True if point onto surface, otherwise false</returns>
 public static Boolean GetElevationAtPK(Alignment align, TinSurface surf, Double pk,
                                 Double offset, out Double elevation)
 {
     elevation = 0.0d;
     try
     {
         var east = 0.0d;
         var north = 0.0d;
         align.PointLocation(pk, offset, ref east, ref north);
         // Get elevation from surface at point
         elevation = surf.FindElevationAtXY(east, north);
     }
     catch (Autodesk.Civil.PointNotOnEntityException)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 15
0
        getAverageElev(ObjectId idPoly, bool boolShowPoints, string strSurface)
        {
            double dblZ_Total = 0;
            double dblZ_AVG   = 0;

            bool       exists         = false;
            ObjectId   idSurfaceEXIST = Surf.getSurface(strSurface, out exists);
            TinSurface surfaceEXIST   = (TinSurface)idSurfaceEXIST.getEnt();

            if (surfaceEXIST.GetGeneralProperties().MinimumElevation <= 0.0)
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(string.Format("Check Surface EXIST elevations: Minimum elevation: {0}", surfaceEXIST.GetGeneralProperties().MinimumElevation));
                return(0);
            }

            using (BaseObjs._acadDoc.LockDocument())
            {
                if (!idPoly.isRightHand())
                {
                    idPoly.reversePolyX();
                }
                idPoly.checkIfClosed();
            }

            Point3dCollection pntsGrid     = Misc.getBldgLimitsAVG(idPoly, 20);
            Point3dCollection pntsGridElev = new Point3dCollection();

            foreach (Point3d pnt3d in pntsGrid)
            {
                try
                {
                    double dblZ = surfaceEXIST.FindElevationAtXY(pnt3d.X, pnt3d.Y);
                    dblZ_Total = dblZ_Total + dblZ;

                    if (boolShowPoints)
                    {
                        pntsGridElev.Add(new Point3d(pnt3d.X, pnt3d.Y, dblZ));
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Grading_Floor.cs: line: 115");
                }
            }

            if (boolShowPoints)
            {
                uint pntNum;

                using (BaseObjs._acadDoc.LockDocument())
                {
                    foreach (Point3d pnt3d in pntsGridElev)
                    {
                        pnt3d.setPoint(out pntNum, "CPNT-ON");
                    }
                }
            }

            dblZ_AVG = dblZ_Total / (pntsGrid.Count);

            return(dblZ_AVG);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Process point below over the scanLine
        /// </summary>
        /// <param name="scanLine">Eeference line used to generate
        /// points</param>
        /// <param name="densityOfPoints">Number of points
        /// per AutoCAD unit of drawing</param>
        /// <param name="increaseOnStep">Reprocess when a step
        /// is identified. Used to control recursion</param>
        private static void ProcessScanLine(LineSegment3d scanLine,
                                            int densityOfPoints, bool increaseOnStep)
        {
            PointOnCurve3d[] pointsOnDatum =
                scanLine.GetSamplePoints(
                    (int)(scanLine.Length * densityOfPoints));
            Point3d lastPointAdded = Point3d.Origin;

            foreach (PointOnCurve3d pointOnDatumCurve in pointsOnDatum)
            {
                Point3d pointOnDatum = new Point3d(
                    pointOnDatumCurve.Point.ToArray());
                double elevationOnSurface =
                    (_surface != null ?
                     _surface.FindElevationAtXY(pointOnDatum.X, pointOnDatum.Y) : // up to elevation of the reference surface
                     _upperLimit);                                                // up to the limit
                Point3d pointOnSurface = new Point3d(
                    pointOnDatum.X, pointOnDatum.Y, elevationOnSurface);

                // check if this point is below the solid
                // by how many hits a vertical line from
                // this point hit the solid. The lower
                // Z value is the one.
                LinearEntity3d lineEnt = new LineSegment3d(
                    pointOnDatum, pointOnSurface);
                Hit[] hits = _brepSolid.GetLineContainment(lineEnt, 1);
                if (hits != null)
                {
                    double lowerZ = hits[0].Point.Z; //double.MaxValue;
                    //foreach (Hit h in hits)
                    //{
                    //  if (h.Point.Z < lowerZ)
                    //    lowerZ = h.Point.Z;
                    //  h.Dispose();
                    //}
                    Point3d pointToAdd = new Point3d(
                        pointOnDatum.X, pointOnDatum.Y, lowerZ);
                    _newPoints.Add(pointToAdd);

                    // increase density on steps (big change on elevation)?
                    // ToDo: Need to implement that on the other direction.
                    //       This is working only over the scan line direction,
                    //       but is also required on the perpendicular
                    if (increaseOnStep)
                    {
                        //skip very first point
                        if (lastPointAdded.DistanceTo(Point3d.Origin) != 0)
                        {
                            if (pointToAdd.DistanceTo(lastPointAdded) >
                                ((1.0 / densityOfPoints) * 10))
                            {
                                double  scanLineElevation = scanLine.StartPoint.Z;
                                Point3d scanLinePt1       = new Point3d(
                                    lastPointAdded.X, lastPointAdded.Y,
                                    scanLineElevation);
                                Point3d scanLinePt2 = new Point3d(
                                    pointToAdd.X, pointToAdd.Y, scanLineElevation);
                                LineSegment3d increaseScanLine = new LineSegment3d(
                                    scanLinePt1, scanLinePt2);
                                ProcessScanLine(increaseScanLine,
                                                densityOfPoints * 10, false);
                                increaseScanLine.Dispose();
                            }
                        }
                        lastPointAdded = pointToAdd;
                    }
                }
                pointOnDatumCurve.Dispose();
            }
        }
Exemplo n.º 17
0
        makePipeNetwork(ObjectId idAlign, string nameNetwork, string pipeType)
        {
            string pntDesc = fMNP.pntDesc;

            Point3d pnt3dPick = Pub.pnt3dO;

            if (idAlign == ObjectId.Null)
            {
                Autodesk.AutoCAD.DatabaseServices.Entity ent = Select.selectEntity(typeof(Alignment), "Select Alignment: ", "Selected object was not an alignment. Try again: ", out pnt3dPick);
                idAlign = ent.ObjectId;
            }

            Network            net   = null;
            ObjectIdCollection ids   = CivilApplication.ActiveDocument.GetPipeNetworkIds();
            ObjectId           idNet = ObjectId.Null;

            if (ids.Count == 0)
            {
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }
            else
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    net = (Network)ids[i].getEnt();
                    //if (net.Name == nameNetwork){
                    //    string index = Align.getAlignIndex(nameNetwork);
                    //    nameNetwork = string.Format("{0}-{1}", nameNetwork, index);
                    //    break;
                    //}
                }
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }

            bool exists = false;

            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            TinSurface tinSurfDE           = Surf.getTinSurface("CPNT-ON", out exists);

            List <AlgnEntData> algnData = MNP_Align.sortAlignEnts(align);
            List <string>      hPipe    = new List <string>();
            List <ObjectId>    idsCgPnt = new List <ObjectId>();

            ObjectId idPipe, idPipeSize, idStruct, idStructSize;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                net = (Network)tr.GetObject(idNet, OpenMode.ForWrite);
                net.ReferenceAlignmentId = idAlign;
                net.ReferenceSurfaceId   = Surf.getTinSurface("CPNT-ON", out exists).ObjectId;

                ObjectId  idPartsList = CivilApplication.ActiveDocument.Styles.PartsListSet["Standard"];
                PartsList partsList   = (PartsList)tr.GetObject(idPartsList, OpenMode.ForRead);

                idPipe = partsList["Concrete Pipe"];
                PartFamily partFamily = (PartFamily)tr.GetObject(idPipe, OpenMode.ForWrite);

                idPipeSize = partFamily[0];

                PartSize        partSize = (PartSize)tr.GetObject(idPipeSize, OpenMode.ForRead);
                PartDataRecord  pdr      = partSize.SizeDataRecord;
                PartDataField[] pdf      = pdr.GetAllDataFields();

                for (int i = 0; i < pdf.Length; i++)
                {
                    System.Diagnostics.Debug.Print(string.Format("{0}: {1}", pdf[i].Description, pdf[i].Value.ToString()));
                }

                idStruct     = partsList["Rectangular Structure Slab Top Rectangular Frame"];
                partFamily   = (PartFamily)tr.GetObject(idStruct, OpenMode.ForWrite);
                idStructSize = partFamily[0];

                double depth = -6, slope = 0, dZ = 0, top = 0;
                double diam = double.Parse(pdf[0].Value.ToString()) / 12;

                ObjectId idPipeNew = ObjectId.Null;

                AlignmentEntity ent    = null;
                Structure       sPrev  = null;
                uint            pntNum = 0;

                ObjectId     idCgPntBeg, idCgPntEnd, idCgPntPrev = ObjectId.Null;
                TypedValue[] tvs;

                for (int i = 0; i < algnData.Count; i++)
                {
                    if (algnData.Count == 1)
                    {
                        ent = ents[0];
                    }
                    else
                    {
                        ent = ents.EntityAtId(algnData[i].ID);
                    }

                    ObjectId  idStructNew = ObjectId.Null;
                    Structure s           = null;
                    Pipe      p           = null;

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

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        LineSegment3d seg3d = new LineSegment3d(pnt3dBeg, pnt3dEnd);

                        net.AddLinePipe(idPipe, idPipeSize, seg3d, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();

                        slope = pnt3dBeg.getSlope(pnt3dEnd);

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            idCgPntPrev = idCgPntEnd;

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd   = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);
                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                    else if (ent.EntityType == AlignmentEntityType.Arc)
                    {
                        AlignmentArc arc    = (AlignmentArc)ent;
                        double       radius = arc.Radius;

                        Point2d pnt2dBeg = arc.StartPoint;
                        Point2d pnt2dEnd = arc.EndPoint;

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }
                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        IntPtr  iptr     = (IntPtr)0;
                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        Arc a = new Arc();
                        a.Radius     = arc.Radius;
                        a.StartPoint = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, 0);
                        a.EndPoint   = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, 0);
                        a.Center     = new Point3d(arc.CenterPoint.X, arc.CenterPoint.Y, 0);

                        Curve3d c = (Curve3d)a.GetGeCurve();

                        net.AddCurvePipe(idPipe, idPipeSize, c, arc.Clockwise, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();
                        slope = (pnt3dEnd.Z - pnt3dBeg.Z) / arc.Length;

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                }
                tr.Commit();
            }

            hPipe.Insert(0, "-1");
            hPipe.Add("-1");

            for (int i = 0; i < idsCgPnt.Count; i++)
            {
                TypedValue[] tvs = new TypedValue[3];
                tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                tvs.SetValue(new TypedValue(1005, hPipe[i]), 1);
                tvs.SetValue(new TypedValue(1005, hPipe[i + 1]), 2);
                idsCgPnt[i].setXData(tvs, apps.lnkMNP);
            }
        }