Ejemplo n.º 1
0
        setPointStyleBOT()
        {
            ObjectId   idPntStyle  = BaseObjs._civDoc.Styles.PointStyles["BOT"];
            PointStyle objPntStyle = default(PointStyle);

            if ((idPntStyle.IsNull))
            {
                objPntStyle = CgPnts.getPntStyle("BOT");
            }

            objPntStyle.MarkerType = PointMarkerDisplayType.UsePointForMarker;
            objPntStyle.GetMarkerDisplayStyleModel().Color   = clr.byl;
            objPntStyle.GetMarkerDisplayStyleModel().Visible = true;
            objPntStyle.GetMarkerDisplayStylePlan().Color    = clr.byl;
            objPntStyle.GetMarkerDisplayStylePlan().Visible  = true;
            objPntStyle.GetLabelDisplayStyleModel().Color    = clr.byl;
            objPntStyle.GetLabelDisplayStyleModel().Visible  = true;
            objPntStyle.GetLabelDisplayStylePlan().Color     = clr.byl;
            objPntStyle.GetLabelDisplayStylePlan().Visible   = true;
        }
Ejemplo n.º 2
0
Archivo: cmdRL.cs Proyecto: 15831944/EM
        RL(string nameApp, string nameCmd)
        {
            ObjectId idPoly = ObjectId.Null;
            bool     escape = false;

            List <ObjectId> idPnts        = new List <ObjectId>();
            ObjectId        idCogoPntBASE = CgPnt.selectCogoPointByNode("\nSelect Base Point: ", osMode: 8);

            if (idCogoPntBASE == ObjectId.Null)
            {
                Application.ShowAlertDialog("CogoPoint not found.  Exiting......");
                return;
            }

            BaseObjs.updateGraphics();
            Point3d pnt3dBASE = idCogoPntBASE.getCogoPntCoordinates();

            idPnts.Add(idCogoPntBASE);

            string pntDesc = idCogoPntBASE.getCogoPntDesc();

            if (pntDesc == "")
            {
                pntDesc = "CPNT-ON";
            }

            string       prompt = "\nLocate New Point: ";
            PromptStatus ps;
            Point3d      pnt3dTAR = UserInput.getPoint(prompt, pnt3dBASE, out escape, out ps, osMode: 641);

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

            double distance = 0.0;
            double DeltaZ   = 0.0;
            double grade    = 0.0;

            resultsRL resRL;

            getRLpromptresults(out resRL, out escape);
            if (escape)
            {
                return;
            }

            switch (resRL.opt)
            {
            case "R":
                grade    = resRL.val;
                distance = pnt3dBASE.getDistance(pnt3dTAR);
                pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dBASE.Z + (grade * distance));
                break;

            case "Z":
                DeltaZ   = resRL.val;
                pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dBASE.Z + DeltaZ);
                break;
            }

            uint     pntNum;
            ObjectId idCogoPntTAR = pnt3dTAR.setPoint(out pntNum, pntDesc);
            ObjectId idPoly3d     = ObjectId.Null;

            if (nameCmd == "cmdRL")
            {
                idPnts.Add(idCogoPntTAR);

                List <Handle> hPnts = new List <Handle>();
                hPnts.Add(idPnts[0].getHandle());
                hPnts.Add(idPnts[1].getHandle());

                using (BaseObjs._acadDoc.LockDocument())
                {
                    idPoly3d = BrkLine.makeBreakline(nameApp, nameCmd, out idPoly, idPnts);
                }
            }

            Grading_Palette.gPalette.pGrading.cmdRL_Default = resRL.opt;
            Grading_Palette.gPalette.pGrading.cmdRL_GRADE   = grade.ToString();
            Grading_Palette.gPalette.pGrading.cmdRL_DELTAZ  = DeltaZ.ToString();

            Dict.setCmdDefault("cmdRL", "cmdDefault", resRL.opt);
            Dict.setCmdDefault("cmdRL", "GRADE", grade.ToString());
            Dict.setCmdDefault("cmdRL", "DELTAZ", DeltaZ.ToString());

            bool       exists          = false;
            PointGroup pntGroup        = CgPnt_Group.addPntGroup(pntDesc, out exists);
            ObjectId   idPntLabelStyle = Pnt_Style.getPntLabelStyle(CgPnts.setup(pntDesc));

            if (!exists)
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        pntGroup.UpgradeOpen();
                        pntGroup.PointLabelStyleId = idPntLabelStyle;

                        StandardPointGroupQuery query = new StandardPointGroupQuery();
                        query.IncludeRawDescriptions = pntDesc;
                        pntGroup.SetQuery(query);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdRL.cs: line: 167");
                }
            }
        }
Ejemplo n.º 3
0
        public static void testBotElev(object[] varGridData, bool boolReTest)
        {
            bool boolProceed = false;
            bool isOX        = false;
            bool isOXg       = false;

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

            Layer.manageLayers("BOT-POINTS");

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

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

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

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

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

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

            EW_Utility1.getTableData();
            TinSurface objSurfaceEXIST = null;

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

            SurfaceDefinitionBoundaries bndrys = objSurfaceEXIST.BoundariesDefinition;

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

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

                //BEGIN BOUNDARY EDIT - ADD X GRID POINTS

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

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

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

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

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

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

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

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

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

                    int k = varPnts3dBndry.Count;

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

                    int intXCounter = 0, intYCounter = 0;

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

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

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

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

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

                                    dblPnts3dBndry.Add(pnt3d);
                                }
                            }

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

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

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

                    //END BOUNDARY EDIT - ADD X GRID POINTS

                    varPnts3dBndry = dblPnts3dBndry;
                    k = varPnts3dBndry.Count;

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

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

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

                        double dblLEN = pnt3dBeg.getDistance(pnt3dEnd);

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

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

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

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

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

                            dblPnts3dBndry.Add(pnt3dEnd);

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

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

                    //END BOUNDARY EDIT - ADD Y GRID POINTS

                    //BEGIN REMOVE DUPLICATE POINTS

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

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

                    //END REMOVE DUPLICATE POINTS

                    //BEGIN TEST ELEVATION ON BOUNDARY

                    k = dblPnts3dBndryRev.Count;

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

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

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

                            double dblZ_MIN = dblZ_R_R;

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

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

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

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

                        ObjectId id3dBndry = Draw.addPoly3d(dblPnts3dBndryRev);

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

                    //END TEST ELEVATION ON BOUNDARY

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

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

                        varPnts3dBndry = dblPnts3dBndryRev;

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

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

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

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

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

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

                                    double dblZ_MIN = dblZ_R_R;

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

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

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

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

                if (boolReTest == false)
                {
                    EW_Main.viewResults("BOT", false);
                }
            }
            catch {
            }
            return;
        }
Ejemplo n.º 4
0
        RTD(string nameApp)
        {
            resultsRTd resRTd = new resultsRTd {
                opt1 = "D", opt2 = "R", valD = 0.0, valE = 0.0, valZ = 0.0, valS = 0.0
            };

            bool escape = false;

            List <ObjectId> idPnts        = new List <ObjectId>();
            ObjectId        idCogoPntBASE = CgPnt.selectCogoPointByNode("\nSelect Base Point: ", osMode: 8);

            if (idCogoPntBASE == ObjectId.Null)
            {
                Application.ShowAlertDialog("CogoPoint not found.  Exiting......");
                return;
            }

            BaseObjs.updateGraphics();
            Point3d pnt3dBASE = idCogoPntBASE.getCogoPntCoordinates();

            idPnts.Add(idCogoPntBASE);

            string pntDesc = idCogoPntBASE.getCogoPntDesc();

            if (pntDesc == "")
            {
                pntDesc = "CPNT-ON";
            }

            string prompt = "\nPick Point for Direction: ";

            PromptStatus ps;
            Point3d      pnt3dTAR = UserInput.getPoint(prompt, pnt3dBASE, out escape, out ps, osMode: 641);

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

            double angle = 0;

            resRTd.opt1 = Dict.getCmdDefault("cmdRTd", "cmdDefault");

            if (resRTd.opt1 == string.Empty)
            {
                resRTd.opt1 = "D";
            }

            angle = Measure.getAzRadians(pnt3dBASE, pnt3dTAR);

            try
            {
                prompt = string.Format("\nDistance / target Elevation / Z value difference <{0}>: [D/E/Z]: ", resRTd.opt1);
                escape = UserInput.getUserInputKeyword(resRTd.opt1, out resRTd.opt1, prompt, "D E Z");
                if (escape)
                {
                    return;
                }
                if (resRTd.opt1 != "D" && resRTd.opt1 != "E" && resRTd.opt1 != "Z")
                {
                    return;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRTD.cs: line: 88");
            }

            if (resRTd.opt1 == string.Empty)
            {
                return;
            }
            bool tryParse = false;

            switch (resRTd.opt1)
            {
            case "D":
                resRTd.valD = Pub.Dist;
                if (resRTd.valD == 0)
                {
                    tryParse = double.TryParse(Dict.getCmdDefault("cmdRTD", "Distance"), out resRTd.valD);
                }

                if (!tryParse)
                {
                    resRTd.valD = 0.0;
                }
                ;

                try
                {
                    escape = UserInput.getUserInput("\nEnter Distance [pos(+) value = target direction, neg(-) value = target direction + 180 degrees:", out resRTd.valD, resRTd.valD);
                    if (escape)
                    {
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdRTD.cs: line: 112");
                }

                Pub.Dist = resRTd.valD;

                resRTd.valS = Pub.Slope;
                if (resRTd.valS == 0.0)
                {
                    tryParse = double.TryParse(Dict.getCmdDefault("cmdRTd", "Slope"), out resRTd.valS);
                }

                escape = UserInput.getUserInput("\nRate of Grade: ", out resRTd.valS, resRTd.valS);
                if (escape)
                {
                    return;
                }

                Pub.Slope = resRTd.valS;

                break;

            case "E":
                resRTd.valE = Pub.Elev;
                if (resRTd.valE == 0)
                {
                    resRTd.valE = double.Parse(Dict.getCmdDefault("cmdRTd", "Elevation"));
                }

                PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter Target Elevation / ESC to select point for Elevation: ");

                pdo.AllowArbitraryInput = true;
                pdo.AllowNone           = true;
                pdo.UseDefaultValue     = true;
                pdo.DefaultValue        = resRTd.valE;

                PromptDoubleResult pdr = BaseObjs._editor.GetDouble(pdo);

                switch (pdr.Status)
                {
                case PromptStatus.Cancel:
                    ObjectId idCgPnt = ObjectId.Null;
                    Point3d  pnt3d   = Pub.pnt3dO;
                    tryParse = double.TryParse(UserInput.getPoint("\nSelect Cogo Point with desired elevation: ",
                                                                  out idCgPnt, out pnt3d, pnt3d, osMode: 8, round: false), out resRTd.valE);
                    if (!tryParse)
                    {
                        break;
                    }
                    break;

                case PromptStatus.Error:
                    break;

                case PromptStatus.Other:
                    break;

                case PromptStatus.OK:
                    resRTd.valE = pdr.Value;
                    break;

                case PromptStatus.None:
                    break;
                }

                Pub.Elev = resRTd.valE;

                prompt = string.Format("\nDistance / Rate of grade <{0}>: [D/R]: ", resRTd.opt2);
                escape = UserInput.getUserInputKeyword(resRTd.opt2, out resRTd.opt2, prompt, "D R");
                if (escape)
                {
                    return;
                }

                switch (resRTd.opt2)
                {
                case "D":
                    resRTd.valD = Pub.Dist;
                    if (resRTd.valD == 0)
                    {
                        tryParse = double.TryParse(Dict.getCmdDefault("cmdRTD", "Distance"), out resRTd.valD);
                    }

                    if (!tryParse)
                    {
                        resRTd.valD = 0.0;
                    }
                    ;

                    try
                    {
                        escape = UserInput.getUserInput("\nEnter Distance [pos(+) value = target direction, neg(-) value = target direction + 180 degrees:", out resRTd.valD, resRTd.valD);
                        if (escape)
                        {
                            return;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdRTD.cs: line: 189");
                    }
                    Pub.Dist = resRTd.valD;

                    break;

                case "R":
                    resRTd.valS = Pub.Slope;
                    if (resRTd.valS == 0.0)
                    {
                        tryParse = double.TryParse(Dict.getCmdDefault("cmdRTd", "Slope"), out resRTd.valS);
                    }

                    escape = UserInput.getUserInput("\nRate of Grade: ", out resRTd.valS, resRTd.valS);
                    if (escape)
                    {
                        return;
                    }

                    Pub.Slope = resRTd.valS;
                    break;
                }

                break;

            case "Z":
                resRTd.valZ = Pub.dZ;

                escape = UserInput.getUserInput("\nZ Value Difference", out resRTd.valZ, resRTd.valZ);

                if (escape)
                {
                    return;
                }

                prompt = string.Format("\nDistance / Rate of grade <{0}>: [D/R]: ", resRTd.opt2);
                escape = UserInput.getUserInputKeyword(resRTd.opt2, out resRTd.opt2, prompt, "D R");
                if (escape)
                {
                    return;
                }

                switch (resRTd.opt2)
                {
                case "D":
                    resRTd.valD = Pub.Dist;
                    if (resRTd.valD == 00)
                    {
                        tryParse = double.TryParse(Dict.getCmdDefault("cmdRTD", "Distance"), out resRTd.valD);
                    }
                    if (!tryParse)
                    {
                        resRTd.valD = 0.0;
                    }
                    try
                    {
                        escape = UserInput.getUserInput("\nEnter Distance [pos(+) value = target direction, neg(-) value = target direction + 180 degrees:", out resRTd.valD, resRTd.valD);
                        if (escape)
                        {
                            return;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdRTD.cs: line: 236");
                    }
                    Pub.Dist = resRTd.valD;

                    break;

                case "R":
                    resRTd.valS = Pub.Slope;
                    if (resRTd.valS == 0.0)
                    {
                        tryParse = double.TryParse(Dict.getCmdDefault("cmdRTd", "Slope"), out resRTd.valS);
                    }

                    escape = UserInput.getUserInput("\nRate of Grade: ", out resRTd.valS, resRTd.valS);
                    if (escape)
                    {
                        return;
                    }
                    Pub.Slope = resRTd.valS;
                    break;
                }
                break;
            }


            switch (resRTd.opt1)
            {
            case "D":
                pnt3dTAR = new Point3d(pnt3dBASE.X + System.Math.Cos(angle) * resRTd.valD,
                                       pnt3dBASE.Y + System.Math.Sin(angle) * resRTd.valD,
                                       pnt3dBASE.Z + resRTd.valS * System.Math.Abs(resRTd.valD));
                break;

            case "E":

                switch (resRTd.opt2)
                {
                case "D":
                    pnt3dTAR = pnt3dBASE.traverse(angle, resRTd.valD, 0);
                    pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, resRTd.valE);
                    break;

                case "R":
                    double distance = System.Math.Abs((resRTd.valE - pnt3dBASE.Z) / resRTd.valS);
                    pnt3dTAR = new Point3d(pnt3dBASE.X + System.Math.Cos(angle) * distance,
                                           pnt3dBASE.Y + System.Math.Sin(angle) * distance,
                                           resRTd.valE);
                    break;
                }
                break;

            case "Z":
                switch (resRTd.opt2)
                {
                case "D":
                    pnt3dTAR = new Point3d(pnt3dBASE.X + System.Math.Cos(angle) * resRTd.valD,
                                           pnt3dBASE.Y + System.Math.Sin(angle) * resRTd.valD,
                                           pnt3dBASE.Z + resRTd.valZ);
                    break;

                case "R":
                    double distance = System.Math.Abs(resRTd.valZ / resRTd.valS);
                    pnt3dTAR = new Point3d(pnt3dBASE.X + System.Math.Cos(angle) * distance,
                                           pnt3dBASE.Y + System.Math.Sin(angle) * distance,
                                           pnt3dBASE.Z + resRTd.valZ);
                    break;
                }
                break;
            }

            uint     pntNum;
            ObjectId idCogoPntTAR = pnt3dTAR.setPoint(out pntNum, pntDesc);
            ObjectId idPoly3d     = ObjectId.Null;

            idPnts.Add(idCogoPntTAR);

            List <Handle> hPnts = new List <Handle>();

            hPnts.Add(idPnts[0].getHandle());
            hPnts.Add(idPnts[1].getHandle());

            ObjectId idPoly = ObjectId.Null;

            using (BaseObjs._acadDoc.LockDocument())
            {
                idPoly3d = BrkLine.makeBreakline(nameApp, "cmdRTd", out idPoly, idPnts);
            }

            Grading_Palette.gPalette.pGrading.cmdRTd_Default   = resRTd.opt1;
            Grading_Palette.gPalette.pGrading.cmdRTd_Distance  = resRTd.valD.ToString();
            Grading_Palette.gPalette.pGrading.cmdRTd_Elevation = resRTd.valE.ToString();
            Grading_Palette.gPalette.pGrading.cmdRTd_Slope     = resRTd.valS.ToString();

            Dict.setCmdDefault("cmdRTd", "cmdDefault", resRTd.opt1);
            Dict.setCmdDefault("cmdRTd", "Distance", resRTd.valD.ToString());
            Dict.setCmdDefault("cmdRTd", "Elevation", resRTd.valE.ToString());
            Dict.setCmdDefault("cmdRTD", "Slope", resRTd.valS.ToString());

            bool       exists          = false;
            PointGroup pntGroup        = CgPnt_Group.addPntGroup(pntDesc, out exists);
            ObjectId   idPntLabelStyle = Pnt_Style.getPntLabelStyle(CgPnts.setup(pntDesc));

            if (!exists)
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        pntGroup.UpgradeOpen();
                        pntGroup.PointLabelStyleId = idPntLabelStyle;

                        StandardPointGroupQuery query = new StandardPointGroupQuery();
                        query.IncludeRawDescriptions = pntDesc;
                        pntGroup.SetQuery(query);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdRTD.cs: line: 343");
                }
            }
        }