Exemple #1
0
 private void cmdResetOX_Click(object sender, RoutedEventArgs e)
 {
     using (BaseObjs._acadDoc.LockDocument())
     {
         resetOX();
         BaseObjs.updateGraphics();
     }
 }
Exemple #2
0
        doMidDelta(int intSide, Point3d pnt3dA, Point3d pnt3dB, Point3d pnt3dC,
                   bool doB1, double B1Width, double B1Slope, bool doB2, double B2Width, double B2Slope,
                   string surfaceTAR, double elev, double slope,
                   ref Point3d pnt3dB1_M, ref Point3d pnt3dB2_M, ref Point3d pnt3dDL_M)
        {
            using (BaseObjs._acadDoc.LockDocument())
            {
                double   dblAngBC  = pnt3dB.getDirection(pnt3dC);
                Vector3d v3d1      = pnt3dB - pnt3dA;
                Vector3d v3d2      = pnt3dC - pnt3dB;
                double   dblAngABC = v3d1.getAngle2Vectors(v3d2);

                uint   pntNum  = 0;
                double dblAngV = dblAngBC + intSide * dblAngABC / 2;
                if (doB1 == true)
                {
                    pnt3dB1_M = pnt3dB.traverse(dblAngV, B1Width, B1Slope);
                    pnt3dB1_M.setPoint(out pntNum, "CPNT-ON");
                    BaseObjs.updateGraphics();
                }
                if (doB2 == true)
                {
                    pnt3dB2_M = pnt3dB.traverse(dblAngV, B2Width, B2Slope);  //temporary point
                    pnt3dB2_M.setPoint(out pntNum, "CPNT-ON");
                    BaseObjs.updateGraphics();
                }

                if (surfaceTAR != "")
                {
                    pnt3dDL_M = getTargetElevation(elev, pnt3dB, dblAngV, slope);
                    pnt3dDL_M.setPoint(out pntNum, "CPNT-ON");
                    BaseObjs.updateGraphics();
                }
                else
                {
                    try
                    {
                        pnt3dDL_M = getTargetElevation(elev, pnt3dB, dblAngV, slope);
                        pnt3dDL_M.setPoint(out pntNum, "CPNT-ON");
                        BaseObjs.updateGraphics();
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " cmdSG.cs: line: 337");
                    }
                }

                if (doB2 == true)
                {
                    pnt3dB2_M = pnt3dDL_M.traverse(dblAngV + PI, B2Width, -B2Slope);
                    pnt3dB2_M.setPoint(out pntNum, "CPNT-ON");
                    BaseObjs.updateGraphics();
                }
            }
        }
Exemple #3
0
        public static void viewResults(string strName, bool boolMake)
        {
            BaseObjs._acadDoc.SendStringToExecute("-UNITS\r2\r3\r1\r5\r0.0\rN\r", true, false, false);
            BaseObjs._acadDoc.SendStringToExecute("-VPOINT\rR\r300\r10\r", true, false, false);
            BaseObjs.updateGraphics();

            string strMessage = null;

            if (boolMake)
            {
                TimeSpan timeSpan = timeEnd - timeBeg;

                strMessage = string.Format("Elapsed Time: {0} \n Select OK to return to PLAN view and create surface {1} or CANCEL to keep current view and return to AutoCAD", timeSpan, strName);
            }
            else
            {
                strMessage = "Select OK to return to PLAN view or CANCEL to keep current view";
            }

            timeEnd = DateTime.Now;

            DialogResult varResponse = MessageBox.Show(strMessage, "CHECK FOR SPIKES", MessageBoxButtons.OKCancel);

            switch (varResponse)
            {
            case DialogResult.OK:

                BaseObjs._acadDoc.SendStringToExecute("PLAN\rW\r", true, false, false);
                if (boolMake)
                {
                    switch (strName)
                    {
                    case "OX":
                    case "OXg":
                    case "SG":
                        EW_MakeSurfaceSG_OX.makeSurface(strName);
                        break;
                    }
                }
                return;
            }
        }
Exemple #4
0
        BD(double B1Width, double B1Slope,
           double B2Width, double B2Slope,
           double gradeSlope, int interval,
           string surfTAR, string surfDES,
           int side          = 0,
           double elev       = 0.0,
           Polyline3d poly3d = null)
        {
            Boolean success = false;
            Boolean exists  = false;

            Boolean doB1 = fSG.boolB1;
            Boolean doB2 = fSG.boolB1;

            List <Point3d> pnts3d   = new List <Point3d>();
            List <Point3d> pnts3dB1 = new List <Point3d>();
            List <Point3d> pnts3dB2 = new List <Point3d>();
            List <Point3d> pnts3dDL = new List <Point3d>();
            List <Point3d> pnts3dRF = new List <Point3d>();

            Vector3d v3d = Vector3d.XAxis;

            Point3d pnt3dB;

            BaseObjs.acadActivate();

            ObjectId idPoly3dOrg = ObjectId.Null;
            ObjectId idPoly3d    = ObjectId.Null;
            ObjectId idPoly      = ObjectId.Null;

            if (poly3d == null)
            {
                idPoly3dOrg = Select.getBrkLine("\nSelect 3D Polyline Reference: ");
            }
            else
            {
                idPoly3dOrg = poly3d.ObjectId;
            }

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

            ResultBuffer rb = idPoly3dOrg.getXData(apps.lnkBrks);

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

            TypedValue[]    tvs        = rb.AsArray();
            List <ObjectId> idsCgPntRF = tvs.getObjectIdList();
            List <ObjectId> idsCgPntM  = null;

            ObjectId idCgPnt = ObjectId.Null;

            bool isClosed = idPoly3dOrg.checkIfClosed3d(false);

            if (!isClosed)
            {
                Application.ShowAlertDialog("Design reference Breakline is not closed. Exiting...");
                return(false);
            }
            Point3d pnt3dB1_Mb = Pub.pnt3dO, pnt3dB2_Mb = Pub.pnt3dO, pnt3dDL_Mb = Pub.pnt3dO, pnt3dRF_Mb = Pub.pnt3dO;
            Point3d pnt3dB1_Me = Pub.pnt3dO, pnt3dB2_Me = Pub.pnt3dO, pnt3dDL_Me = Pub.pnt3dO, pnt3dRF_Me = Pub.pnt3dO;
            Point3d pnt3dX = Pub.pnt3dO, pnt3dXA = Pub.pnt3dO, pnt3dXB = Pub.pnt3dO;

            uint   pntNum = 0;
            int    s = 0;
            double angle = 0.0, deflc = 0.0, delta = 0.0, slopeChk = 0.0;

            List <ANG_PT_PROP> angPtProps = new List <ANG_PT_PROP>();
            ANG_PT_PROP        angPtProp  = null;

            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    pnts3d = idPoly3dOrg.getCoordinates3dList();

                    if (side == 0)
                    {
                        side = Geom.getSide(pnts3d);
                    }

                    angPtProps = pnts3d.getPoly3dAngPtProps();

                    int k = angPtProps.Count;
                    for (int i = 0; i < k; i++)
                    {
                        angPtProp = angPtProps[i];

                        pnt3dB = angPtProp.BEG;     //last point = first point

                        deflc = angPtProp.ANG_DEFLC;

                        if (i == 0)
                        {
                            pnts3dRF.Add(pnt3dB);       //add begin point
                        }
                        angle = getMidDeltaDirection(side, deflc, angPtProp.DIR_SEG1, angPtProp.DIR_SEG2, out s);


                        if (s == 0)
                        {
                            if (surfTAR == "")
                            {
                                pnt3dDL_Mb = getTargetElevation(elev, pnt3dB, angle, gradeSlope);
                            }
                            else
                            {
                                v3d        = new Vector3d(sMath.Cos(angle), sMath.Sin(angle), -gradeSlope);
                                pnt3dDL_Mb = getSlopeIntercept(surfTAR, pnt3dB, gradeSlope, v3d);
                            }

                            pnts3dDL.Add(pnt3dDL_Mb);

                            idCgPnt = pnt3dDL_Mb.setPoint(out pntNum);
                            BaseObjs.updateGraphics();

                            idsCgPntM = new List <ObjectId> {
                                idsCgPntRF[i], idCgPnt
                            };
                            idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                            BaseObjs.updateGraphics();
                        }
                        else if (s == -2 || s == 4)
                        {
                            getToeIntercept(side, angPtProp, surfTAR, elev, gradeSlope, doB1, B1Width, B1Slope, doB2, B2Width, B2Slope, ref pnt3dDL_Mb, ref pnt3dXA, ref pnt3dXB);

                            if (i == 0)
                            {
                                pnt3dDL_Me = pnt3dXB;
                            }
                            else
                            {
                                pnts3dRF.Add(pnt3dXB);
                                pnt3dXB.setPoint(out pntNum, "CPNT-ON");
                                BaseObjs.updateGraphics();
                            }

                            slopeChk = pnt3dDL_Mb.getSlope(pnt3dXB);
                            Debug.Print(slopeChk.ToString("0.0000"));

                            pnts3dRF.Add(pnt3dB);          //add RF Angle point

                            pnts3dRF.Add(pnt3dXA);
                            pnt3dXA.setPoint(out pntNum, "CPNT-ON");
                            BaseObjs.updateGraphics();

                            slopeChk = pnt3dDL_Mb.getSlope(pnt3dXA);
                            Debug.Print(slopeChk.ToString("0.0000"));

                            idCgPnt = pnt3dDL_Mb.setPoint(out pntNum, "CPNT-ON");
                            BaseObjs.updateGraphics();
                            idsCgPntM = new List <ObjectId> {
                                idsCgPntRF[i], idCgPnt
                            };
                            pnts3dDL.Add(pnt3dDL_Mb);

                            idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                            BaseObjs.updateGraphics();
                        }
                        else if (s == 2 || s == -4)
                        {
                            pnts3dRF.Add(pnt3dB);

                            double   anglePerp1 = angPtProp.DIR_SEG1 + PI / 2 * -side;
                            double   anglePerp2 = angPtProp.DIR_SEG2 + PI / 2 * -side;
                            Vector2d v2d1       = new Vector2d(sMath.Cos(anglePerp1), sMath.Sin(anglePerp1));
                            Vector2d v2d2       = new Vector2d(sMath.Cos(anglePerp2), sMath.Sin(anglePerp2));

                            delta = v2d1.GetAngleTo(v2d2);

                            List <double> angles = new List <double>();
                            angles.Add(anglePerp1);
                            double angleX = anglePerp1 + delta / 4 * side;
                            angles.Add(angleX);
                            angles.Add(angle);
                            angleX = angle + delta / 4 * side;
                            angles.Add(angleX);
                            angles.Add(anglePerp2);



                            foreach (double ang in angles)
                            {
                                angle = ang;
                                if (surfTAR != "")
                                {
                                    v3d        = new Vector3d(sMath.Cos(angle), sMath.Sin(angle), -gradeSlope);
                                    pnt3dDL_Mb = getSlopeIntercept(surfTAR, pnt3dB, gradeSlope, v3d);
                                }
                                else
                                {
                                    pnt3dDL_Mb = getTargetElevation(elev, pnt3dB, angle, gradeSlope);
                                }

                                pnts3dDL.Add(pnt3dDL_Mb);
                                idCgPnt = pnt3dDL_Mb.setPoint(out pntNum, "CPNT-ON");
                                BaseObjs.updateGraphics();

                                idsCgPntM = new List <ObjectId> {
                                    idsCgPntRF[i], idCgPnt
                                };

                                idPoly3d = BrkLine.makeBreakline(apps.lnkSLP, "cmdBD", out idPoly, idsCgPntM);
                                BaseObjs.updateGraphics();
                            }
                        }
                    }

                    pnts3dDL.Add(pnts3dDL[0]);  //complete point list with first point - for closure
                    if (pnt3dRF_Me != Pub.pnt3dO)
                    {
                        pnts3dRF.Add(pnt3dRF_Me);   //point on RF opposite DL back - first mid delta
                        pnt3dRF_Me.setPoint(out pntNum, "CPNT-ON");
                        BaseObjs.updateGraphics();
                    }

                    pnts3dRF.Add(pnts3dRF[0]);  //complete point list with first point - for closure
                }
            }
            catch (SystemException ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdBD.cs: line: 244");
                success = false;
            }
            ObjectId           idPoly3dX  = ObjectId.Null;
            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();

            tvs = new TypedValue[13];
            tvs.SetValue(new TypedValue(1001, "lnkSLP"), 0);
            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    idPoly3dOrg.handOverPoly3d2(pnts3dRF);

                    Handle hB1;
                    if (pnts3dB1.Count > 0)
                    {
                        idPoly3dX = pnts3dB1.addPoly3d("CPNT-BRKLINE"); //Lower Bench
                        idsPoly3dX.Add(idPoly3dX);
                        hB1 = idPoly3dX.getHandle();
                    }
                    else
                    {
                        B1Width = 0.0;
                        B1Slope = 0.0;
                        hB1     = "0".stringToHandle();
                    }
                    tvs.SetValue(new TypedValue(1000, B1Width), 1);
                    tvs.SetValue(new TypedValue(1000, B1Slope), 2);
                    tvs.SetValue(new TypedValue(1005, hB1), 3);

                    Handle hB2;
                    if (pnts3dB2.Count > 0)
                    {
                        idPoly3dX = pnts3dB2.addPoly3d("CPNT-BRKLINE"); //Top of Slope/Upper Bench
                        idsPoly3dX.Add(idPoly3dX);
                        hB2 = idPoly3dX.getHandle();
                    }
                    else
                    {
                        B2Width = 0.0;
                        B2Slope = 0.0;
                        hB2     = "0".stringToHandle();
                    }
                    tvs.SetValue(new TypedValue(1000, B2Width), 4);
                    tvs.SetValue(new TypedValue(1000, B2Slope), 5);
                    tvs.SetValue(new TypedValue(1005, hB2), 6);

                    Handle hDL;
                    idPoly3dX = pnts3dDL.addPoly3d("CPNT-BRKLINE"); //Top of Slope/Daylight (if no upper bench)
                    idsPoly3dX.Add(idPoly3dX);

                    hDL = idPoly3dX.getHandle();
                    tvs.SetValue(new TypedValue(1000, gradeSlope), 7);
                    tvs.SetValue(new TypedValue(1070, side), 8);
                    tvs.SetValue(new TypedValue(1000, interval), 9);
                    tvs.SetValue(new TypedValue(1005, hDL), 10);
                    tvs.SetValue(new TypedValue(1000, surfTAR), 11);
                    tvs.SetValue(new TypedValue(1000, surfDES), 12);

                    idPoly3dOrg.setXData(tvs, apps.lnkSLP);
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdBD.cs: line: 307");
                }
            }

            if (idPoly3dX != ObjectId.Null)
            {
                DialogResult result;
                result = MessageBox.Show(string.Format("Add Slope Breaklines to Design Surface? \nYes to add to surface: {0}\nNo to keep Breaklines, but not add to surface.\nCancel to dispose of Breaklines.", surfDES),
                                         "Slope Breaklines",
                                         System.Windows.Forms.MessageBoxButtons.YesNoCancel);
                switch (result)
                {
                case DialogResult.Yes:
                    TinSurface surf = Surf.getTinSurface(surfDES, out exists);
                    surf.BreaklinesDefinition.AddStandardBreaklines(idsPoly3dX, 1.0, 1.0, 0.0, 0.0);
                    success = true;
                    break;

                case DialogResult.No:
                    success = true;
                    break;

                case DialogResult.Cancel:
                    success = false;
                    break;
                }
            }
            else
            {
                success = false;
            }

            return(success);
        }
Exemple #5
0
        addBrklineSegmentsDock(this List <Point3d> pnts3d, out ObjectIdCollection idsPoly3d, string nameApp, int side,
                               ObjectId idCgPntBeg, ObjectId idCgPntEnd, int indexPntEnd = 0)
        {
            idsPoly3d = new ObjectIdCollection();
            uint pntNum = 0;

            List <ObjectId> idCgPntList = new List <ObjectId>();
            ObjectId        idCgPnt0 = ObjectId.Null, idCgPnt1 = ObjectId.Null, idPoly3d = ObjectId.Null;

            int n = pnts3d.Count;

            for (int i = 1; i < n; i++)
            {
                if (i == 1)
                {                              //first segment
                    idCgPnt0 = idCgPntBeg;
                    idCgPntList.Add(idCgPnt0); //overall list

                    idCgPnt1 = pnts3d[1].setPoint(out pntNum);
                    idCgPntList.Add(idCgPnt1);

                    idPoly3d = Draw.addPoly3d(idCgPnt0, idCgPnt1, nameApp, "CPNT-BRKLINE");
                    idsPoly3d.Add(idPoly3d);
                    BaseObjs.updateGraphics();
                }
                else if (i == n - 1)        //last vertex
                {
                    if (indexPntEnd == 0)
                    {
                        idCgPnt0 = idCgPntEnd;
                        idCgPntList.Add(idCgPnt0);
                    }
                    else
                    {
                        idCgPnt0 = idCgPntList[i - 1];
                    }

                    idCgPnt1 = idCgPntBeg;

                    idPoly3d = Draw.addPoly3d(idCgPnt0, idCgPnt1, nameApp, "CPNT-BRKLINE");
                    idsPoly3d.Add(idPoly3d);
                    BaseObjs.updateGraphics();
                }
                else
                {
                    if (i == indexPntEnd || i == indexPntEnd + 1)
                    {
                        if (i == indexPntEnd)
                        {
                            idCgPnt0 = idCgPntList[i - 1];

                            idCgPnt1 = idCgPntEnd;
                            idCgPntList.Add(idCgPnt1);
                        }
                        else if (i == indexPntEnd + 1)
                        {
                            idCgPnt0 = idCgPntEnd;
                            idCgPntList.Add(idCgPnt0);

                            idCgPnt1 = pnts3d[i].setPoint(out pntNum);
                            idCgPntList.Add(idCgPnt1);
                        }
                    }
                    else
                    {
                        idCgPnt0 = idCgPntList[i - 1];

                        idCgPnt1 = pnts3d[i].setPoint(out pntNum);
                        idCgPntList.Add(idCgPnt1);
                    }

                    idPoly3d = Draw.addPoly3d(idCgPnt0, idCgPnt1, nameApp, "CPNT-BRKLINE");
                    idsPoly3d.Add(idPoly3d);
                    BaseObjs.updateGraphics();
                }
            }
            return(idCgPntList);
        }
Exemple #6
0
        TP1()
        {
            elev = UserInput.getCogoPoint("\nPick Cogo Point 1: ", out idCgPnt1, ObjectId.Null, osMode: 8);
            if (elev == "")
            {
                return;
            }
            idsCgPnt.Add(idCgPnt1);

            elev = UserInput.getCogoPoint("\nPick Cogo Point 2: ", out idCgPnt2, idCgPnt1, osMode: 8);
            if (elev == "")
            {
                return;
            }
            idsCgPnt.Add(idCgPnt2);

            escaped = UserInput.getUserInputDoubleAsString("\nEnter Cross Slope (+ or -): ", out xSlope, xSlope);
            if (escaped)
            {
                return;
            }

            escaped = UserInput.getUserInputDoubleAsString("\nEnter Width: ", out width, width);
            if (escaped)
            {
                return;
            }

            Point3d        pnt3d1 = idCgPnt1.getCogoPntCoordinates();
            Point3d        pnt3d2 = idCgPnt2.getCogoPntCoordinates();
            List <Point3d> pnts3d = new List <Point3d> {
                pnt3d1, pnt3d2
            };

            int side = Geom.getSide(pnts3d);

            double dir = pnt3d1.getDirection(pnt3d2);
            double len = pnt3d1.getDistance(pnt3d2);

            Point3d  pnt3d3   = pnt3d2.traverse(dir + pi / 2 * -side, double.Parse(width), double.Parse(xSlope));
            ObjectId idCgPnt3 = pnt3d3.setPoint(out pntNum);

            idsCgPnt.Add(idCgPnt3);
            BaseObjs.updateGraphics();

            Point3d  pnt3d4   = pnt3d1.traverse(dir + pi / 2 * -side, double.Parse(width), double.Parse(xSlope));
            ObjectId idCgPnt4 = pnt3d4.setPoint(out pntNum);

            idsCgPnt.Add(idCgPnt4);
            BaseObjs.updateGraphics();

            idsCgPnt.Add(idCgPnt1);

            ObjectId idPoly = ObjectId.Null;

            List <ObjectId> idCgPnts = new List <ObjectId> {
                idCgPnt1, idCgPnt2
            };

            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt2, idCgPnt3
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt3, idCgPnt4
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt4, idCgPnt1
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);
        }
Exemple #7
0
        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");
                }
            }
        }
        trimEdgeToCurb(ObjectId idBlockRef, ObjectIdCollection idsPoly3d, ObjectId idPoly3dRF, List <Handle> handles3)
        {
            bool     ints     = false;
            ObjectId idPolyLT = handles3[1].getObjectId();
            ObjectId idPolyRT = handles3[3].getObjectId();

            List <Point3d> pnt3dBox = new List <Point3d> {
                idPolyRT.getBegPnt(),
                           idPolyRT.getEndPnt(),
                           idPolyLT.getEndPnt(),
                           idPolyLT.getBegPnt(),
            };

            pnt3dBox.Add(pnt3dBox[0]);

            ObjectId idPolyBox  = Draw.addPoly(pnt3dBox);
            Entity   entPolyBox = idPolyBox.getEnt();

            string nameLayer = "CURB-TEMP";

            Layer.manageLayers(nameLayer);
            ResultBuffer rb = null;

            try {
                ObjectIdCollection idsEntTemp = xRef.copyXRefEnts(idBlockRef, "CURB", nameLayer);

                BaseObjs.updateGraphics();
                ObjectIdCollection idsEnts = new ObjectIdCollection();

                try {
                    for (int i = idsEntTemp.Count - 1; i > -1; i--)
                    {
                        Debug.Print(i.ToString());
                        ObjectId idEnt = idsEntTemp[i];
                        Entity   ent   = idEnt.getEnt();
                        if (ent == null)
                        {
                            continue;
                        }

                        Point3dCollection pnts3dInt0 = new Point3dCollection();

                        switch (idEnt.getType())
                        {
                        case "Arc":
                        case "Line":
                            idEnt.changeProp(LineWeight.LineWeight050, clr.mag);
                            BaseObjs.updateGraphics();

                            ent.BoundingBoxIntersectWith(entPolyBox, Intersect.OnBothOperands, pnts3dInt0, IntPtr.Zero, IntPtr.Zero);

                            if (pnts3dInt0.Count > 0)
                            {
                                idsEnts.Add(idEnt);
                                idEnt.changeProp(LineWeight.LineWeight100, clr.cyn);
                                BaseObjs.updateGraphics();
                            }
                            else
                            {
                                idEnt.delete();
                            }
                            break;

                        case "Polyline":

                            List <ObjectId> idsPolyEnts = idEnt.poly_ArcsLines(nameLayer);
                            idEnt.delete();
                            idsEntTemp.Remove(idEnt);

                            foreach (ObjectId idx in idsPolyEnts)
                            {
                                ent = idx.getEnt();
                                idx.changeProp(LineWeight.LineWeight050, clr.mag);
                                BaseObjs.updateGraphics();

                                pnts3dInt0 = new Point3dCollection();

                                ent.BoundingBoxIntersectWith(entPolyBox, Intersect.OnBothOperands, pnts3dInt0, IntPtr.Zero, IntPtr.Zero);

                                if (pnts3dInt0.Count > 0)
                                {
                                    idsEnts.Add(idx);
                                    idsEntTemp.Add(idx);
                                    idx.changeProp(LineWeight.LineWeight100, clr.cyn);
                                    BaseObjs.updateGraphics();
                                }
                                else
                                {
                                    idx.delete();
                                }
                            }
                            break;

                        case "Spline":
                            string message = "\nWarning: Drawing containing the curb objects contains Splines.\nReplace the Splines with Lines, Arcs, or Polylines and reprocess.\nExiting...";
                            Application.ShowAlertDialog(message);
                            idsEntTemp.delete();
                            return(false);

                        default:
                            idEnt.delete();
                            idsEntTemp.Remove(idEnt);
                            break;
                        }
                    }
                }
                catch (System.Exception) {
                }
                finally{
                    idPolyBox.delete();
                }

                if (idsEnts.Count == 0)
                {
                    return(ints);
                }

                CogoPoint cogoPntBEG;

                Handle[] hPolysIn = new Handle[4];
                handles3.CopyTo(hPolysIn);

                for (int n = 0; n < idsPoly3d.Count; n++)
                {
                    bool delete = false;
                    bool exists = false;

                    List <Point3d> pnt3dIntL   = new List <Point3d>();
                    List <Point3d> pnt3dRevL   = new List <Point3d>();
                    List <Point3d> pnt3dFinalL = new List <Point3d>();

                    ObjectId idPoly3dEDGE = idsPoly3d[n];
                    Handle   h            = idPoly3dEDGE.getHandle();

                    ObjectId idPolyEDGE = hPolysIn[n * 2 + 1].getObjectId();
                    h = idPolyEDGE.getHandle();

                    double lenEDGE = idPolyEDGE.getLength();                        //2dPoly IS DERIVED FROM REFERENCE 3DPOLYLINE in cmdBV
                    double deltaZ  = 0;

                    Polyline polyEDGE = (Polyline)idPolyEDGE.getEnt();

                    ObjectIdCollection idsDelete = new ObjectIdCollection();
                    try {
                        foreach (ObjectId idEnt in idsEnts)
                        {
                            Entity ent = idEnt.getEnt();

                            if (ent is Arc)
                            {
                                try {
                                    Arc arc = (Arc)ent;
                                    idEnt.changeProp(clr.red);
                                    BaseObjs.updateGraphics();

                                    Point3d        pnt3dPolyBeg = polyEDGE.ObjectId.getBegPnt();
                                    Point3d        pnt3dPolyEnd = polyEDGE.ObjectId.getEndPnt();
                                    List <Point3d> pnts3dPoly   = new List <Point3d> {
                                        pnt3dPolyBeg, pnt3dPolyEnd
                                    };
                                    List <Point3d> pnt3dIntLx = new List <Point3d>();
                                    bool           intersects = Geom.intersectsArc(pnts3dPoly, arc, out pnt3dIntLx, ref idsDelete);
                                    foreach (Point3d p3d in pnt3dIntLx)
                                    {
                                        pnt3dIntL.Add(p3d);
                                    }
                                }
                                catch (System.Exception) {
                                }
                            }
                            else
                            {
                                try {
                                    idEnt.changeProp(clr.yel);
                                    BaseObjs.updateGraphics();
                                    Point3dCollection pnt3dIntC = new Point3dCollection();
                                    polyEDGE.IntersectWith(ent, 0, pnt3dIntC, IntPtr.Zero, IntPtr.Zero);
                                    foreach (Point3d pnt3d in pnt3dIntC)
                                    {
                                        pnt3dIntL.Add(pnt3d);
                                    }
                                }
                                catch (System.Exception) {
                                }
                            }
                        }
                        idsDelete.delete();
                        BaseObjs.updateGraphics();
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception) {
                    }
                    finally {
                    }
                    if (pnt3dIntL.Count > 0)
                    {
                        delete = true;
                        ints   = true;
                        rb     = idPoly3dRF.getXData(apps.lnkBrks2);                                        //poly3dEDGE stores FL/RF cogo points at each end
                        if (rb == null)
                        {
                            return(false);
                        }
                        List <Handle>    handles2 = rb.rb_handles();                                             //list of handles of points at each end of FL/RF
                        List <CogoPoint> cogoPnts = handles2.getCogoPntsFromHandlesList();
                        cogoPntBEG = cogoPnts[0];

                        ObjectId idDictM   = Dict.getNamedDictionary(apps.lnkBrks3, out exists);
                        ObjectId idDictBEG = Dict.getSubEntry(idDictM, handles2[0].ToString());
                        ObjectId idDictEND = Dict.getSubEntry(idDictM, handles2[1].ToString());
                        ObjectId idDictX   = ObjectId.Null;

                        idDictX = Dict.getSubEntry(idDictBEG, idPoly3dEDGE.getHandle().ToString());
                        rb      = Dict.getXRec(idDictX, "Offset");
                        if (rb == null)
                        {
                            return(false);
                        }
                        TypedValue[] TVs    = rb.AsArray();
                        double       offset = (double)TVs[0].Value;

                        rb     = Dict.getXRec(idDictX, "DeltaZ");
                        TVs    = rb.AsArray();
                        deltaZ = (double)TVs[0].Value;

                        Point3d pnt3dFLbeg = cogoPntBEG.Location;

                        Point3d pnt3dEDGEbeg = idPoly3dEDGE.getBegPnt();
                        Point3d pnt3dEDGEend = idPoly3dEDGE.getEndPnt();

                        double slopeEdge = (pnt3dEDGEend.Z - pnt3dEDGEbeg.Z) / pnt3dEDGEbeg.getDistance(pnt3dEDGEend);

                        pnt3dRevL.Add(new Point3d(pnt3dEDGEbeg.X, pnt3dEDGEbeg.Y, 0.0)); //start list with begin point of edge
                        pnt3dRevL.Add(pnt3dIntL[0]);                                     //add first intersection

                        double angle    = pnt3dEDGEbeg.getDirection(pnt3dFLbeg);
                        double distance = pnt3dEDGEbeg.getDistance(pnt3dFLbeg);
                        double slope    = pnt3dEDGEbeg.getSlope(pnt3dFLbeg);


                        distance = distance * 1.1;

                        for (int i = 1; i < pnt3dIntL.Count; i++)
                        {
                            if (pnt3dIntL[i - 1].isEqual(pnt3dIntL[i - 0], 0.1) == false)
                            {
                                pnt3dRevL.Add(pnt3dIntL[i]);
                            }
                        }

                        pnt3dRevL.Add(new Point3d(pnt3dEDGEend.X, pnt3dEDGEend.Y, 0.0));

                        List <PNT_LIST> pntList = new List <PNT_LIST>();
                        short           x       = -1;
                        foreach (Point3d pnt3d in pnt3dRevL)
                        {
                            pntList.Add(new PNT_LIST {
                                index  = ++x,
                                length = pnt3dEDGEbeg.getDistance(pnt3d)
                            });
                        }

                        var sortDist = from pntlst in pntList
                                       orderby pntlst.length ascending
                                       select pntlst;

                        foreach (PNT_LIST pntLst in sortDist)
                        {
                            pnt3dFinalL.Add(pnt3dRevL[pntLst.index]);
                        }

                        for (int i = 1; i < pnt3dFinalL.Count; i++)
                        {
                            double distX = pnt3dFinalL[i - 1].getDistance(pnt3dFinalL[i]);
                            if (distX == 0)
                            {
                                pnt3dFinalL.Remove(pnt3dFinalL[i]);
                            }
                        }


                        if (pnt3dFinalL.Count > 1)
                        {
                            idsDelete = new ObjectIdCollection();
                            for (int i = 1; i < pnt3dFinalL.Count; i++)
                            {
                                bool     curb     = false;
                                Point3d  pnt3dMID = pnt3dFinalL[i - 1].getMidPoint2d(pnt3dFinalL[i + 0]);
                                Point3d  pnt3dTAR = pnt3dMID.traverse(angle, distance);
                                ObjectId idLine   = Base_Tools45.Draw.addLine(pnt3dMID, pnt3dTAR);
                                Line     line     = (Line)idLine.getEnt();
                                BaseObjs.updateGraphics();

                                Point3dCollection pnts3dInts = new Point3dCollection();
                                for (int j = idsEnts.Count - 1; j > -1; j--)
                                {
                                    ObjectId idEnt = idsEnts[j];
                                    Entity   ent   = idEnt.getEnt();
                                    if (ent is Arc)
                                    {
                                        Arc arc = (Arc)ent;

                                        List <Point3d> pnts3dLine = new List <Point3d> {
                                            pnt3dMID, pnt3dTAR
                                        };
                                        List <Point3d> pnt3dIntLx = new List <Point3d>();
                                        bool           intersects = Geom.intersectsArc(pnts3dLine, arc, out pnt3dIntLx, ref idsDelete);
                                        foreach (Point3d p3d in pnt3dIntLx)
                                        {
                                            pnts3dInts.Add(p3d);
                                        }
                                    }
                                    else
                                    {
                                        Point3dCollection pnt3dIntC = new Point3dCollection();
                                        line.IntersectWith(ent, 0, pnt3dIntC, IntPtr.Zero, IntPtr.Zero);
                                        foreach (Point3d pnt3d in pnt3dIntC)
                                        {
                                            pnts3dInts.Add(pnt3d);
                                        }
                                    }
                                }
                                if (pnts3dInts.Count > 0)
                                {
                                    curb = true;
                                }

                                if (!curb)                                   //'IF NO CURB THEN BUILD 3DPOLY SEGMENT
                                {
                                    Point3dCollection pnts3d  = new Point3dCollection();
                                    double            distBEG = pnt3dEDGEbeg.getDistance(pnt3dFinalL[i - 1]);
                                    pnts3d.Add(new Point3d(pnt3dFinalL[i - 1].X, pnt3dFinalL[i - 1].Y, pnt3dEDGEbeg.Z + distBEG * slopeEdge));

                                    double distEND = pnt3dEDGEbeg.getDistance(pnt3dFinalL[i + 0]);
                                    pnts3d.Add(new Point3d(pnt3dFinalL[i + 0].X, pnt3dFinalL[i + 0].Y, pnt3dEDGEbeg.Z + distEND * slopeEdge));

                                    ObjectId idPoly = Base_Tools45.Draw.addPoly(pnts3d, "GUTTER");
                                    handles3.Add(idPoly.getHandle());



                                    if (distBEG == 0 && System.Math.Round(distEND, 3) == System.Math.Round(lenEDGE))
                                    {
                                        distEND = -1;
                                    }
                                }
                                line.ObjectId.delete();
                            }
                            if (delete)                               //'REMOVE  ORGINAL BREAKLINE DATA FROM EXTENSION DICTIONARY
                            {
                                handles3.Remove(idPolyEDGE.getHandle());

                                Misc.deleteObj(idPolyEDGE);
                            }
                        }
                    }
                    else                        // no intersection with curb
                    {
                        idPolyEDGE.changeProp(nameLayer: "GUTTER");
                    }
                }                // end loop

                idsEntTemp.delete();

                idPoly3dRF.setXData(handles3, apps.lnkBrks3);
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_GetNestedCurbObjects.cs: line: 414");
            }
            return(ints);
        }
Exemple #9
0
        doStretchMove(List <EM_EData> enData)
        {
            foreach (EM_EData eData in enData)
            {
                List <ObjectId> ids = null;
                ObjectId        idP3d, idLdr;
                List <Handle>   handles = null;
                ObjectId        idCgPnt, idMTxt;
                bool            exists;

                TypedValue[] tvs     = eData.tvs;
                string       nameApp = tvs[0].Value.ToString();

                switch (nameApp)
                {
                case apps.lnkGS:
                    switch (eData.objType)
                    {
                    case "CogoPoint":
                        idCgPnt = eData.id;
                        Grading_Utility.updateGS(tvs, "Grip_Stretch_Move");
                        break;

                    case "MText":
                        idMTxt = eData.id;
                        LdrText_Move.moveLdrGS(idMTxt, tvs, eData.pnt3d);
                        break;

                    case "Leader":
                        idLdr = eData.id;
                        LdrText_Move.moveTxtGS(idLdr, tvs);
                        break;
                    }
                    break;

                case apps.lnkBrks:
                    ids     = tvs.getObjectIdList();
                    handles = tvs.getHandleList();

                    foreach (Handle handle in handles)
                    {
                        idP3d = Grading_Utility.update3dPoly_lnkBrks1_2(apps.lnkBrks, eData.id, handle);
                        if (idP3d == ObjectId.Null)
                        {
                            handles.Remove(handle);
                        }
                    }
                    break;

                case apps.lnkBrks2:
                    ids     = tvs.getObjectIdList();
                    handles = tvs.getHandleList();
                    foreach (Handle handle in handles)
                    {
                        idP3d = Grading_Utility.update3dPoly_lnkBrks1_2(apps.lnkBrks2, eData.id, handle);
                        if (idP3d == ObjectId.Null)
                        {
                            handles.Remove(handle);
                        }
                    }
                    ObjectId idDictM   = Dict.getNamedDictionary(apps.lnkBrks3, out exists);
                    ObjectId idDictPnt = Dict.getSubEntry(idDictM, eData.id.getHandle().ToString());

                    List <DBDictionaryEntry> entries = Dict.getEntries(idDictPnt);
                    foreach (DBDictionaryEntry entry in entries)
                    {
                        ObjectId idDictX = Dict.getSubEntry(idDictPnt, entry.Key);

                        ResultBuffer rb2 = Dict.getXRec(idDictX, "Offset");
                        tvs = rb2.AsArray();
                        double offset = (double)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "DeltaZ");
                        tvs = rb2.AsArray();
                        double deltaZ = (double)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "HandleFL");
                        tvs = rb2.AsArray();
                        Handle handleFL = (Handle)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "Beg");
                        tvs = rb2.AsArray();
                        double beg = (double)tvs[0].Value;

                        rb2 = Dict.getXRec(idDictX, "End");
                        tvs = rb2.AsArray();
                        double end = (double)tvs[0].Value;

                        Grading_Utility.update3dPoly_lnkBrks3(idDictX.getHandle(), offset, deltaZ, handleFL, beg, end);
                    }
                    break;

                case apps.lnkBubs:
                    switch (eData.objType)
                    {
                    case "MText":
                        BB_Events.modTXlnkBubs(eData.id, tvs);
                        break;

                    case "Leader":
                        BB_Events.modLDRlnkBubs(eData.id, tvs);
                        break;
                    }
                    break;

                case apps.lnkCO:
                case apps.lnkLD:
                    switch (eData.objType)
                    {
                    case "CogoPoint":
                        idCgPnt = eData.id;
                        idMTxt  = tvs.getObjectId(3);
                        ResultBuffer rbMTxt  = idMTxt.getXData(nameApp);
                        TypedValue[] tvsMTxt = rbMTxt.AsArray();

                        idLdr = tvsMTxt.getObjectId(3);
                        Point3d pnt3dCgPoint = idCgPnt.getCogoPntCoordinates();
                        Point3d pnt3dLdr     = idLdr.getBegPnt();
                        if (!pnt3dCgPoint.X.Equals(pnt3dLdr.X) || !pnt3dCgPoint.Y.Equals(pnt3dLdr.Y))
                        {
                            idLdr.adjLdrBegPnt(pnt3dCgPoint);
                        }
                        Grading_Utility.updatePntCalloutElev(pnt3dCgPoint.Z, tvs);
                        break;

                    case "MText":
                        idMTxt = eData.id;
                        try
                        {
                            LdrText_Move.moveTX(idMTxt, tvs, eData.pnt3d);
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " EM_StretchMove.cs: line: 147");
                        }
                        break;

                    case "Leader":
                        idLdr = eData.id;
                        LdrText_Rotate.adjTxt(idLdr, nameApp);
                        break;
                    }
                    break;


                //case apps.lnkLD:
                //    switch (eData.objType)
                //    {
                //        case "CogoPoint":
                //            break;

                //        case "MText":
                //            idMTxt = eData.id;
                //            try
                //            {
                //                LdrText_Move.moveTX(idMTxt, tvs, eData.pnt3d);
                //            }
                //            catch (System.Exception ex)
                //            {
                //                BaseObjs.writeDebug(string.Format("{0} EM_StretchMove.cs: line: 138", ex.Message));
                //            }
                //            break;

                //        case "Leader":
                //            idLdr = eData.id;
                //            LdrText_Rotate.adjTxt(idLdr, nameApp);
                //            break;
                //    }
                //    break;

                case apps.lnkDimPL:
                    if (eData.objType == "MText")
                    {
                        idMTxt = eData.id;
                        DimPL_Move.modTXlnkDimPl(idMTxt, tvs, idMTxt.getMTextLocation());
                    }
                    break;

                case apps.lnkMNP:
                    ObjectId id = eData.id;
                    switch (eData.objType)
                    {
                    case "Pipe":
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            Pipe pipe = (Pipe)tr.GetObject(id, OpenMode.ForWrite);
                            idCgPnt = tvs.getObjectId(1);
                            CogoPoint cgPNt = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite);

                            double dZ  = pipe.InnerDiameterOrWidth / (2 * System.Math.Cos(System.Math.Atan(System.Math.Abs(pipe.Slope))));
                            double inv = pipe.StartPoint.Z - dZ;
                            cgPNt.Elevation = inv;

                            ResultBuffer rb = idCgPnt.getXData(apps.lnkCO);
                            if (rb != null)
                            {
                                TypedValue[] tvsCgPNt = rb.AsArray();

                                Grading.Grading_Utility.updatePntCalloutElev(inv, tvsCgPNt);
                                BaseObjs.updateGraphics();
                            }

                            idCgPnt         = tvs.getObjectId(2);
                            cgPNt           = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite);
                            inv             = pipe.EndPoint.Z - dZ;
                            cgPNt.Elevation = inv;

                            rb = idCgPnt.getXData(apps.lnkCO);
                            if (rb != null)
                            {
                                TypedValue[] tvsCgPNt = rb.AsArray();

                                Grading.Grading_Utility.updatePntCalloutElev(inv, tvsCgPNt);
                                BaseObjs.updateGraphics();
                            }
                            tr.Commit();
                        }

                        break;

                    case "Structure":
                        Structure s = (Structure)id.getEnt();
                        break;
                    }
                    break;
                }
            }
        }
Exemple #10
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");
                }
            }
        }
Exemple #11
0
        planeMethod(this Arc arc, Point3d pnt3dBeg, Point3d pnt3dEnd, Point3d pnt3dPI, Vector3d v3dM, ref List <ObjectId> idsCgPnt, string nameCmd)
        {
            List <Point3d> pnts3d = new List <Point3d>();

            double delta      = arc.TotalAngle;
            double increDelta = delta / 4;

            double increX = increDelta * arc.Radius;

            Point3d pnt3dM1 = arc.GetPointAtDist(arc.Length * 1 / 4);                //1st quarter delta on arc
            Point3d pnt3dM2 = arc.GetPointAtDist(arc.Length * 2 / 4);                //2nd quarter delta on arc
            Point3d pnt3dM3 = arc.GetPointAtDist(arc.Length * 3 / 4);                //3rd quarter delta on arc

            Vector3d v3dPI = pnt3dPI - pnt3dBeg;                                     //vector from beg to PI

            Vector3d v3dM1 = pnt3dM1 - pnt3dBeg;                                     //vector from beg to 1st quarter delta on arc
            Vector3d v3dM2 = pnt3dM2 - pnt3dBeg;                                     //vector from beg to 2nd quarter delta on arc
            Vector3d v3dM3 = pnt3dM3 - pnt3dBeg;                                     //vector from beg to 3rd quarter delta on arc

            Vector3d v3dC = pnt3dEnd - pnt3dBeg;                                     //vector from beg to end of arc - long chord

            double delta0  = v3dPI.getAngle2Vectors(v3dC);                           //delta / 2
            double deltaM1 = v3dM1.getAngle2Vectors(v3dC);                           //delta from long chord to 1st quarter point
            double deltaM2 = v3dM2.getAngle2Vectors(v3dC);                           //delta from long chord to 2nd quarter point
            double deltaM3 = v3dM3.getAngle2Vectors(v3dC);                           //delta from long chord to 3rd quarter point

            double lenC0 = pnt3dBeg.getDistance(pnt3dEnd);                           //length of long chord
            double lenC1 = pnt3dBeg.getDistance(pnt3dM1) * System.Math.Cos(deltaM1); //length of chord from beg to 1st quarter delta
            double lenC2 = pnt3dBeg.getDistance(pnt3dM2) * System.Math.Cos(deltaM2); //length of chord from beg to 2nd quarter delta
            double lenC3 = pnt3dBeg.getDistance(pnt3dM3) * System.Math.Cos(deltaM3); //length of chord from beg to 3rd quarter delta

            Point3d pnt3dC1 = pnt3dBeg + v3dC * lenC1 / lenC0;                       //point on long chord based on ratio of quarter chords vs long chord
            Point3d pnt3dC2 = pnt3dBeg + v3dC * lenC2 / lenC0;
            Point3d pnt3dC3 = pnt3dBeg + v3dC * lenC3 / lenC0;

            double lenPI = pnt3dC2.getDistance(pnt3dPI);      //middle ordinate + external distance

            uint     pntNum;
            ObjectId idcgPnt = pnt3dC1.setPoint(out pntNum);

            idcgPnt = pnt3dC2.setPoint(out pntNum);
            idcgPnt = pnt3dC3.setPoint(out pntNum);
            BaseObjs.updateGraphics();

            pnt3dM1 = pnt3dC1 + v3dM * pnt3dBeg.getDistance(pnt3dM1) * System.Math.Sin(deltaM1) / lenPI;
            pnt3dM2 = pnt3dC2 + v3dM * pnt3dBeg.getDistance(pnt3dM2) * System.Math.Sin(deltaM2) / lenPI;
            pnt3dM3 = pnt3dC3 + v3dM * pnt3dBeg.getDistance(pnt3dM3) * System.Math.Sin(deltaM3) / lenPI;

            ObjectId idCgPntM1 = pnt3dM1.setPoint(out pntNum);
            ObjectId idCgPntM2 = pnt3dM2.setPoint(out pntNum);
            ObjectId idCgPntM3 = pnt3dM3.setPoint(out pntNum);

            BaseObjs.updateGraphics();

            idsCgPnt.Add(idCgPntM1);
            idsCgPnt.Add(idCgPntM2);
            idsCgPnt.Add(idCgPntM3);

            Point3d pnt3d = pnt3dBeg;

            pnts3d.Add(pnt3d);

            double m1 = (pnt3dM1.Z - pnt3dBeg.Z) / (arc.Length / 4);
            double m2 = (pnt3dM2.Z - pnt3dM1.Z) / (arc.Length / 4);
            double m3 = (pnt3dM3.Z - pnt3dM2.Z) / (arc.Length / 4);
            double m4 = (pnt3dEnd.Z - pnt3dM3.Z) / (arc.Length / 4);

            double elev = 0.0;
            double sta  = 0.0;

            for (int i = 1; i < 5; i++)
            {
                sta  += increX;
                pnt3d = arc.GetPointAtDist(sta);

                switch (i)
                {
                case 1:
                    elev = pnt3dBeg.Z + sta * m1;
                    break;

                case 2:
                    elev = pnt3dM1.Z + increX * m2;
                    break;

                case 3:
                    elev = pnt3dM2.Z + increX * m3;
                    break;

                case 4:
                    elev = pnt3dM3.Z + increX * m4;
                    break;
                }

                pnt3d = new Point3d(pnt3d.X, pnt3d.Y, elev);
                pnts3d.Add(pnt3d);
            }

            return(pnts3d);
        }
Exemple #12
0
        planeMethodModified(this Arc arc, Point3d pnt3dBeg, Point3d pnt3dEnd, Point3d pnt3dPI, Vector3d v3dM, double g1, double g2, ref List <ObjectId> idsCgPnt)
        {
            double delta      = arc.TotalAngle;
            double increDelta = delta / 4;

            double increX = increDelta * arc.Radius;

            Point3d pnt3dM1 = arc.GetPointAtDist(arc.Length * 1 / 4);                //1st quarter delta on arc
            Point3d pnt3dM2 = arc.GetPointAtDist(arc.Length * 2 / 4);                //2nd quarter delta on arc
            Point3d pnt3dM3 = arc.GetPointAtDist(arc.Length * 3 / 4);                //3rd quarter delta on arc

            Vector3d v3dPI = pnt3dPI - pnt3dBeg;                                     //vector from beg to PI

            Vector3d v3dM1 = pnt3dM1 - pnt3dBeg;                                     //vector from beg to 1st quarter delta on arc
            Vector3d v3dM2 = pnt3dM2 - pnt3dBeg;                                     //vector from beg to 2nd quarter delta on arc
            Vector3d v3dM3 = pnt3dM3 - pnt3dBeg;                                     //vector from beg to 3rd quarter delta on arc

            Vector3d v3dC = pnt3dEnd - pnt3dBeg;                                     //vector from beg to end of arc - long chord

            double delta0  = v3dPI.getAngle2Vectors(v3dC);                           //delta / 2
            double deltaM1 = v3dM1.getAngle2Vectors(v3dC);                           //delta from long chord to 1st quarter point
            double deltaM2 = v3dM2.getAngle2Vectors(v3dC);                           //delta from long chord to 2nd quarter point
            double deltaM3 = v3dM3.getAngle2Vectors(v3dC);                           //delta from long chord to 3rd quarter point

            double lenC0 = pnt3dBeg.getDistance(pnt3dEnd);                           //length of long chord
            double lenC1 = pnt3dBeg.getDistance(pnt3dM1) * System.Math.Cos(deltaM1); //length of chord from beg to 1st quarter delta
            double lenC2 = pnt3dBeg.getDistance(pnt3dM2) * System.Math.Cos(deltaM2); //length of chord from beg to 2nd quarter delta
            double lenC3 = pnt3dBeg.getDistance(pnt3dM3) * System.Math.Cos(deltaM3); //length of chord from beg to 3rd quarter delta

            Point3d pnt3dC1 = pnt3dBeg + v3dC * lenC1 / lenC0;                       //point on long chord based on ratio of quarter chords vs long chord
            Point3d pnt3dC2 = pnt3dBeg + v3dC * lenC2 / lenC0;
            Point3d pnt3dC3 = pnt3dBeg + v3dC * lenC3 / lenC0;

            double lenPI = pnt3dC2.getDistance(pnt3dPI);      //middle ordinate + external distance

            uint     pntNum;
            ObjectId idcgPnt = pnt3dC1.setPoint(out pntNum);    //points on long chord

            idcgPnt = pnt3dC2.setPoint(out pntNum);             //points on long chord
            idcgPnt = pnt3dC3.setPoint(out pntNum);             //points on long chord
            BaseObjs.updateGraphics();

            Point3d pnt3dT1 = pnt3dC1.traverse(pnt3dC2.getDirection(pnt3dPI), pnt3dBeg.getDistance(pnt3dC1) * System.Math.Tan(v3dPI.getAngle2Vectors(pnt3dEnd - pnt3dBeg)));
            Point3d pnt3dT3 = pnt3dC3.traverse(pnt3dC2.getDirection(pnt3dPI), pnt3dEnd.getDistance(pnt3dC3) * System.Math.Tan((pnt3dPI - pnt3dEnd).getAngle2Vectors(pnt3dBeg - pnt3dEnd)));

            BaseObjs.updateGraphics();

            pnt3dT1 = new Point3d(pnt3dT1.X, pnt3dT1.Y, pnt3dBeg.Z + pnt3dBeg.getDistance(pnt3dT1) * g1);
            pnt3dT1.setPoint(out pntNum);
            Vector3d v3dT1 = pnt3dT1 - pnt3dC1;

            pnt3dT3 = new Point3d(pnt3dT3.X, pnt3dT3.Y, pnt3dEnd.Z + pnt3dEnd.getDistance(pnt3dT3) * g2);
            pnt3dT3.setPoint(out pntNum);
            Vector3d v3dT3 = pnt3dT3 - pnt3dC3;

            pnt3dM1 = pnt3dC1 + v3dT1 * pnt3dC1.getDistance(pnt3dM1) / pnt3dC1.getDistance(pnt3dT1);
            pnt3dM2 = pnt3dC2 + v3dM * pnt3dBeg.getDistance(pnt3dM2) * System.Math.Sin(deltaM2) / lenPI;
            pnt3dM3 = pnt3dC3 + v3dT3 * pnt3dC3.getDistance(pnt3dM3) / pnt3dC3.getDistance(pnt3dT3);

            ObjectId idCgPntM1 = pnt3dM1.setPoint(out pntNum);
            ObjectId idCgPntM2 = pnt3dM2.setPoint(out pntNum);
            ObjectId idCgPntM3 = pnt3dM3.setPoint(out pntNum);

            BaseObjs.updateGraphics();

            idsCgPnt.Add(idCgPntM1);
            idsCgPnt.Add(idCgPntM2);
            idsCgPnt.Add(idCgPntM3);

            List <Point3d> pnts3d = new List <Point3d> {
                pnt3dBeg, pnt3dM1, pnt3dM2, pnt3dM3, pnt3dEnd
            };

            return(pnts3d);
        }
Exemple #13
0
        processArcs(List <Arc> arcs, List <arcInfo> arcInfos, Arc arc0, List <ObjectId> idsCgPnt, string nameCmd, List <double> offHs, List <double> offVs)
        {
            ObjectId      idPoly  = ObjectId.Null;
            List <Handle> handles = new List <Handle>();
            ObjectId      idFL    = ObjectId.Null;

            for (int y = 0; y < arcs.Count; y++)
            {
                Arc            arc    = arcs[y];
                List <Point3d> pnts3d = new List <Point3d>();

                for (int p = 0; p < arcInfos.Count - 1; p++)
                {
                    Vector3d v3dBeg = new Vector3d(0, 0, 0);
                    Vector3d v3dEnd = new Vector3d(0, 0, 0);
                    for (int a = 0; a < y + 1; a++)
                    {
                        v3dBeg += arcInfos[p].v3ds[a];
                        v3dEnd += arcInfos[p + 1].v3ds[a];
                    }
                    Point3d pnt3dBeg = arcInfos[p].idCgPnt.getCogoPntCoordinates();
                    pnt3dBeg += v3dBeg;

                    Point3d pnt3dEnd = arcInfos[p + 1].idCgPnt.getCogoPntCoordinates();
                    pnt3dEnd += v3dEnd;

                    double dist = arcInfos[p].distToNext * arcs[y].Length / arc0.Length;

                    double grd = (pnt3dEnd.Z - pnt3dBeg.Z) / dist;

                    double staBeg = arcInfos[p].distFromBeg * arcs[y].Length / arc0.Length;
                    arc.traverse(pnt3dBeg, grd, dist, staBeg, ref pnts3d);
                }

                ObjectId idBrk = ObjectId.Null;

                if (y == 0)
                {
                    idFL = BrkLine.makeBreakline(apps.lnkBrks3, nameCmd, out idPoly, idsCgPnt, pnts3dL: pnts3d);
                    foreach (ObjectId id in idsCgPnt)
                    {
                        id.updatePntXData(idFL, apps.lnkBrks2);
                    }
                }
                else
                {
                    idBrk = BrkLine.makeBreakline(apps.lnkBrks, nameCmd, out idPoly, idsCgPnt, pnts3dL: pnts3d);
                    Grading_Dict.addBrksToPntXDict(idFL, idBrk, offHs[y], offVs[y], 0.0, -1);
                    if (y == 2)
                    {
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                            idPoly = arcs[2].convertArcToPolyline("GB");
                            tr.Commit();
                        }
                        idPoly.moveBottom();
                        idBrk.moveToTop();
                    }
                    handles.Add(idBrk.getHandle());
                }

                BaseObjs.updateGraphics();
            }

            idFL.setXData(handles, apps.lnkBrks3);
        }
Exemple #14
0
        ABC(string nameCmd)
        {
            Arc arc0 = null;

            Point3d pnt3dBeg = Pub.pnt3dO, pnt3dEnd = Pub.pnt3dO, pnt3dX = Pub.pnt3dO;

            ObjectId idCgPntEnd = ObjectId.Null;
            ObjectId idPoly     = ObjectId.Null;

            List <Point3d> pnts3d = null, pnts3dEntX = null;

            bool              escape    = true;
            Object            xRefPathX = null;
            PromptStatus      ps;
            FullSubentityPath path;
            Point3d           pnt3dPick;
            bool              isClosed = false;

            double grd = 0.0;
            Entity ent = xRef.getNestedEntity("\nSelect ARC: ", out escape, out xRefPathX, out ps, out pnts3dEntX, out path, out pnt3dPick, out isClosed);

            if (ent.GetType().ToString() != "Autodesk.AutoCAD.DatabaseServices.Arc")
            {
                Application.ShowAlertDialog(string.Format("Selected object was type of: {0} - Exiting...", ent.GetType().ToString()));
                return;
            }
            else
            {
                arc0 = (Arc)ent;
            }

            pnt3dX = UserInput.getPoint("\nPick point Back of Curb adjacent to arc segment", arc0.StartPoint, out escape, out ps, osMode: 8);

            double distX = arc0.Center.getDistance(pnt3dX);

            if (distX == arc0.Radius)
            {
                Application.ShowAlertDialog("Selected point is on arc.  Select point away from street side: ");
                pnt3dX = UserInput.getPoint("\nPick point Back of Curb adjacent to arc segment", pnt3dBeg, out escape, out ps, osMode: 8);
                distX  = arc0.Center.getDistance(pnt3dX);
                if (distX == arc0.Radius)
                {
                    return;
                }
            }

            int side = -1;
            int n    = (arc0.Normal.Z > 0) ? 1 : -1;

            switch (n)
            {
            case 1:                     //right hand direction
                if (distX > arc0.Radius)
                {
                    side = 1;
                }
                break;

            case -1:                    //left hand direction
                if (distX < arc0.Radius)
                {
                    side = 1;
                }
                break;
            }

            string elev = "", prompt = "\nSelect Cogo Point for begin elevation at beginning of curve (as indicated by guideline): ";

            ObjectId idCgPntBeg = getEndPoint(pnt3dBeg, out elev, prompt);

            if (elev == "")
            {
                return;
            }

            List <ObjectId> idsCgPnt = new List <ObjectId>();

            idsCgPnt.Add(idCgPntBeg);

            pnt3dBeg = idCgPntBeg.getCogoPntCoordinates();
            BaseObjs.write(string.Format("\nBegin Elevation = {0:F2}", elev));

            if (arc0.EndPoint.isEqual(pnt3dBeg, 0.1))
            {
                Curve curve = arc0;
                curve.ReverseCurve();                                     //*****************************************************************************
            }
            else if (arc0.StartPoint.isEqual(pnt3dBeg, 0.1))
            {
            }
            else
            {
                Application.ShowAlertDialog("Selected Begin point is not at either end of the arc.  Revise and retry...");
                return;
            }

            uint pntNum = 0;

            ObjectId idCgPntX = ObjectId.Null;

            List <double> userInput = null;

            userInput = cmdBC.getUserInput(nameCmd);
            if (userInput == null)
            {
                return;
            }

            double offH1 = 0.5 * 1.25 * side;
            double offV1 = userInput[0] + 0.0208;
            double offH2 = userInput[1] * side;
            double offV2 = userInput[2] * userInput[1];
            double offH3 = 0;
            double offV3 = 0;

            List <double> offHs = new List <double> {
                0.0, offH1, offH2
            };
            List <double> offVs = new List <double> {
                0.0, offV1, offV2
            };

            List <Arc> arcs = new List <Arc>();

            arcs.Add(arc0);

            DBObjectCollection dbObjs = arc0.GetOffsetCurves(offH1);
            Arc arc1 = (Arc)dbObjs[0];

            arcs.Add(arc1);
            dbObjs = arc1.GetOffsetCurves(offH2);
            Arc arc2 = (Arc)dbObjs[0];

            arcs.Add(arc2);
            Arc arc3 = null;

            if (nameCmd == "cmdABG")
            {
                offH3 = (userInput[3] * side * -1) - offH1 - offH2;  //offset from bench
                offV3 = userInput[4] - offV1 - offV2;                //offset from bench
                offHs.Add(offH3);
                offVs.Add(offV3);

                dbObjs = arc0.GetOffsetCurves(userInput[3] * side * -1);
                arc3   = (Arc)dbObjs[0];
                arcs.Add(arc3);
            }

            string cmdDefault = "R";

            prompt = string.Format("\nStraight grade(two or more points)/slope Intercept/Vertical curve/Plane method/Modified plane method/Reinhard plane method: S/I/V/P/M/R <{0}> [S/I/V/P/M/R]:", cmdDefault);
            escape = UserInput.getUserInputKeyword(cmdDefault, out cmdDefault, prompt, "S I V P M R");
            if (escape)
            {
                return;
            }

            Vector3d v3dBeg = new Vector3d(0, 0, 0);
            Vector3d v3dEnd = new Vector3d(0, 0, 0);

            List <arcInfo> arcInfos = new List <arcInfo>();

            arcInfo aInfo = getArcInfo(pnt3dBeg, arc0, nameCmd, offHs, offVs, idCgPntBeg);

            arcInfos.Add(aInfo);


            Point3d pnt3d = pnt3dBeg;

            switch (cmdDefault)
            {
                #region "S"

            case "S":                                                                   // Assuming points are set at both ends, with optional points set at intermediate locations on arc
                bool Done = false;
                do
                {
                    prompt     = "\nSelect Cogo Point on Arc (Arc endpoint or intermediate point) ENTER when done: ";
                    idCgPntEnd = getEndPoint(pnt3d, out elev, prompt);
                    if (elev == "")
                    {
                        Done = true;
                    }
                    else
                    {
                        pnt3d = idCgPntEnd.getCogoPntCoordinates();
                        idsCgPnt.Add(idCgPntEnd);

                        aInfo = getArcInfo(pnt3d, arc0, nameCmd, offHs, offVs, idCgPntEnd);
                        arcInfos.Add(aInfo);
                    }
                }while (!Done);

                var sortByLen = from a in arcInfos
                                orderby a.distFromBeg ascending
                                select a;
                int i = -1;
                foreach (var b in sortByLen)
                {
                    arcInfos[++i] = b;
                }

                processArcInfo(ref arcInfos);

                switch (idsCgPnt.Count)
                {
                case 1:
                    return;

                default:
                    processArcs(arcs, arcInfos, arc0, idsCgPnt, nameCmd, offHs, offVs);
                    break;
                }

                break;

                #endregion "S"

                #region "I"

            case "I":

                double m1 = Pub.slp1;
                double m2 = Pub.slp2;

                prompt     = "\nSelect Cogo Point for end elevation: ";
                idCgPntEnd = getEndPoint(pnt3dBeg, out elev, prompt);
                if (elev == "")
                {
                    return;
                }
                pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();
                idsCgPnt.Add(idCgPntEnd);

                grd = (pnt3dEnd.Z - pnt3dBeg.Z) / arc0.Length;
                BaseObjs.write(string.Format("\nSlope along curve is: {0:P2}", grd));

                m1 = Pub.slp1;
                m2 = Pub.slp2;

                UserInput.getUserInput("\nEnter slope from FIRST POINT: ", out m1, m1);
                if (m1 == -99.99)
                {
                    return;
                }
                UserInput.getUserInput("\nEnter slope from SECOND POINT: ", out m2, m2);
                if (m2 == -99.99)
                {
                    return;
                }

                Pub.slp1 = m1;
                Pub.slp2 = m2;

                double elev1 = pnt3dBeg.Z;
                double elev2 = pnt3dEnd.Z;
                distX = cmdSSP.getSlopeInterceptArc(arc0.Length, elev1, elev2, m1, -m2);
                if (distX == 0)
                {
                    return;
                }

                Point3d pnt3dInt = arc0.GetPointAtDist(distX);
                pnt3dInt = new Point3d(pnt3dInt.X, pnt3dInt.Y, elev1 + distX * m1);
                ObjectId idCgPntInt = pnt3dInt.setPoint(out pntNum);
                idsCgPnt.Add(idCgPntInt);

                Application.ShowAlertDialog(string.Format("The elevation of the slope\nintercept is {0:F2}", pnt3dInt.Z));


                aInfo = getArcInfo(pnt3dInt, arc0, nameCmd, offHs, offVs, idCgPntInt);
                arcInfos.Add(aInfo);


                aInfo = getArcInfo(pnt3dEnd, arc0, nameCmd, offHs, offVs, idCgPntEnd);
                arcInfos.Add(aInfo);


                processArcInfo(ref arcInfos);

                processArcs(arcs, arcInfos, arc0, idsCgPnt, nameCmd, offHs, offVs);

                break;

                #endregion "I"

                #region "V"

            case "V":
                prompt     = "\nSelect Cogo Point for end elevation: ";
                idCgPntEnd = getEndPoint(pnt3dBeg, out elev, prompt);
                if (elev == "")
                {
                    return;
                }
                pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();
                idsCgPnt.Add(idCgPntEnd);

                grd = (pnt3dEnd.Z - pnt3dBeg.Z) / arc0.Length;
                BaseObjs.write(string.Format("\nSlope along curve is: {0:P2}", grd));

                m1 = Pub.slp1;
                m2 = Pub.slp2;

                UserInput.getUserInput("\nEnter slope from FIRST POINT: ", out m1, m1);
                if (m1 == -99.99)
                {
                    return;
                }
                UserInput.getUserInput("\nEnter slope from SECOND POINT: ", out m2, m2);
                if (m2 == -99.99)
                {
                    return;
                }
                string lenVC = "20";
                escape = UserInput.getUserInputDoubleAsString("\nEnter length of vertical curve: ", out lenVC, lenVC);
                if (escape)
                {
                    return;
                }

                Pub.slp1 = m1;
                Pub.slp2 = m2;

                elev1 = pnt3dBeg.Z;
                elev2 = pnt3dEnd.Z;
                distX = cmdSSP.getSlopeInterceptArc(arc0.Length, elev1, elev2, m1, -m2);
                if (distX == 0)
                {
                    return;
                }

                pnt3dInt = arc0.GetPointAtDist(distX);
                pnt3dInt = new Point3d(pnt3dInt.X, pnt3dInt.Y, elev1 + distX * m1);

                Application.ShowAlertDialog(string.Format("The elevation of the slope\nintercept is {0:F2}", pnt3dInt.Z));

                double lVC = double.Parse(lenVC);
                if ((distX - lVC / 2) < 0 || (distX + lVC / 2) > arc0.Length)
                {
                    double lenMax = distX * 2;
                    if ((arc0.Length - distX) < lenMax / 2)
                    {
                        lenMax = (arc0.Length - distX) * 2;
                        Application.ShowAlertDialog(string.Format("Maximum length of Vertical Curve length with current inputs is {0:F2}", lenMax));
                    }
                }

                pnts3d = arc0.traverse(m1, -m2, distX, lVC, pnt3dBeg);

                BrkLine.makeBreakline(apps.lnkBrks, nameCmd, out idPoly, idsCgPnt, pnts3dL: pnts3d);
                break;

                #endregion "V"

                #region "M"

            case "M":
                prompt = "\nSelect Begin Curve backsight Cogo Point for grade and direction: ";
                Point3d pnt3dBegBS = UserInput.getPoint(prompt, pnt3dBeg, out escape, out ps, osMode: 8);
                if (pnt3dBegBS == Pub.pnt3dO)
                {
                    return;
                }

                prompt     = "\nSelect Cogo Point for end elevation: ";
                idCgPntEnd = getEndPoint(pnt3dBeg, out elev, prompt);
                if (elev == "")
                {
                    return;
                }
                pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();

                grd = (pnt3dEnd.Z - pnt3dBeg.Z) / arc0.Length;
                BaseObjs.write(string.Format("\nSlope along curve is: {0:P2}", grd));

                prompt = "\nSelect End Curve backsight Cogo Point for grade and direction: ";
                Point3d pnt3dEndBS = UserInput.getPoint(prompt, pnt3dEnd, out escape, out ps, osMode: 8);
                if (pnt3dEndBS == Pub.pnt3dO)
                {
                    return;
                }

                Point3d pnt3dPI = Geom.getPntInt(pnt3dBegBS, pnt3dBeg, pnt3dEndBS, pnt3dEnd, true, extend.both);

                double g1 = pnt3dBegBS.getSlope(pnt3dBeg);
                double g2 = pnt3dEnd.getSlope(pnt3dEndBS);

                double el1 = pnt3dBeg.Z + g1 * pnt3dBeg.getDistance(pnt3dPI);
                double el2 = pnt3dEnd.Z - g2 * pnt3dEnd.getDistance(pnt3dPI);

                double ratio = 0;

                double aDiff = g1 - g2;
                double el    = 0;

                if (g1 < 0 && g2 < 0)
                {
                    ratio = g1 / (g1 + g2);
                    if (g1 <= g2)
                    {     //g1 controls
                        if (el1 < el2)
                        {
                            el = el1 + (el2 - el1) * ratio;
                        }
                        else if (el1 > el2)
                        {
                            el = el1 - (el1 - el2) * ratio;
                        }
                    }
                    else if (g2 < g1)
                    {     //g2 controls
                        if (el2 < el1)
                        {
                            el = el2 + (el1 - el2) * (1 - ratio);
                        }
                        else if (el2 > el1)
                        {
                            el = el2 - (el2 - el1) * (1 - ratio);
                        }
                    }
                }
                else if (g1 > 0 && g2 > 0)
                {
                    ratio = g1 / (g1 + g2);
                    if (g1 >= g2)
                    {     //g1 controls
                        if (el1 < el2)
                        {
                            el = el1 + (el2 - el1) * ratio;
                        }
                        else if (el1 > el2)
                        {
                            el = el1 - (el1 - el2) * ratio;
                        }
                    }
                    else if (g2 > g1)
                    {     //g2 controls
                        if (el2 < el1)
                        {
                            el = el2 + (el1 - el2) * (1 - ratio);
                        }
                        else if (el2 > el1)
                        {
                            el = el2 - (el2 - el1) * (1 - ratio);
                        }
                    }
                }
                else
                {
                    ratio = g1 / aDiff;
                    if (ratio >= (1 - ratio))
                    {     //g1 controls
                        if (el1 < el2)
                        {
                            el = el1 + (el2 - el1) * ratio;
                        }
                        else if (el1 > el2)
                        {
                            el = el1 - (el1 - el2) * ratio;
                        }
                    }
                    else if ((1 - ratio) > ratio)
                    {     //g2 controls
                        if (el2 < el1)
                        {
                            el = el2 + (el1 - el2) * (1 - ratio);
                        }
                        else if (el2 > el1)
                        {
                            el = el2 - (el2 - el1) * (1 - ratio);
                        }
                    }
                }

                pnt3dPI = new Point3d(pnt3dPI.X, pnt3dPI.Y, el);
                pnt3dPI.setPoint(out pntNum);
                BaseObjs.updateGraphics();

                double g1Mod = pnt3dBeg.getSlope(pnt3dPI);
                double g2Mod = pnt3dPI.getSlope(pnt3dEnd);

                g1 = (g1 + g1Mod) / 2;
                g2 = (g2 + g2Mod) / 2;

                Point3d pnt3dChordMid = pnt3dBeg.getMidPoint3d(pnt3dEnd);

                Vector3d v3dM = pnt3dPI - pnt3dChordMid;

                pnts3d = arc0.planeMethodModified(pnt3dBeg, pnt3dEnd, pnt3dPI, v3dM, g1, g2, ref idsCgPnt);
                idsCgPnt.Add(idCgPntEnd);

                arcInfos = new List <arcInfo>();
                for (int s = 0; s < pnts3d.Count; s++)
                {
                    pnt3dX = pnts3d[s];
                    aInfo  = getArcInfo(pnt3dX, arc0, nameCmd, offHs, offVs, idsCgPnt[s]);
                    arcInfos.Add(aInfo);
                }

                processArcInfo(ref arcInfos);
                processArcs(arcs, arcInfos, arc0, idsCgPnt, nameCmd, offHs, offVs);

                break;

                #endregion "M"

                #region "R"

            case "R":
                prompt     = "\nSelect Begin Curve backsight Cogo Point for grade and direction: ";
                pnt3dBegBS = UserInput.getPoint(prompt, pnt3dBeg, out escape, out ps, osMode: 8);
                if (pnt3dBegBS == Pub.pnt3dO)
                {
                    return;
                }

                prompt     = "\nSelect Cogo Point for end elevation: ";
                idCgPntEnd = getEndPoint(pnt3dBeg, out elev, prompt);
                if (elev == "")
                {
                    return;
                }
                pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();

                grd = (pnt3dEnd.Z - pnt3dBeg.Z) / arc0.Length;
                BaseObjs.write(string.Format("\nSlope along curve is: {0:P2}", grd));

                prompt     = "\nSelect End Curve backsight Cogo Point for grade and direction: ";
                pnt3dEndBS = UserInput.getPoint(prompt, pnt3dEnd, out escape, out ps, osMode: 8);
                if (pnt3dEndBS == Pub.pnt3dO)
                {
                    return;
                }

                pnt3dPI = Geom.getPntInt(pnt3dBegBS, pnt3dBeg, pnt3dEndBS, pnt3dEnd, true, extend.both);

                g1 = pnt3dBegBS.getSlope(pnt3dBeg);
                g2 = pnt3dEnd.getSlope(pnt3dEndBS);
                string resOut = "";

                prompt = string.Format("\nUse g1={0:P2} or g2={1:P2}?: [1/2]", g1, g2);
                escape = UserInput.getUserInputKeyword("1", out resOut, prompt, "1 2");
                if (escape)
                {
                    return;
                }

                el = 0;
                switch (resOut)
                {
                case "1":
                    el = pnt3dBeg.Z + g1 * pnt3dBeg.getDistance(pnt3dPI);
                    break;

                case "2":
                    el = pnt3dEnd.Z - g2 * pnt3dEnd.getDistance(pnt3dPI);
                    break;
                }

                pnt3dPI = new Point3d(pnt3dPI.X, pnt3dPI.Y, el);
                pnt3dPI.setPoint(out pntNum);
                BaseObjs.updateGraphics();

                pnts3d = arc0.planeMethodReinhard(pnt3dBeg, pnt3dEnd, pnt3dPI, ref idsCgPnt);
                idsCgPnt.Add(idCgPntEnd);

                arcInfos = new List <arcInfo>();
                for (int s = 0; s < pnts3d.Count; s++)
                {
                    pnt3dX = pnts3d[s];
                    aInfo  = getArcInfo(pnt3dX, arc0, nameCmd, offHs, offVs, idsCgPnt[s]);
                    arcInfos.Add(aInfo);
                }

                processArcInfo(ref arcInfos);
                processArcs(arcs, arcInfos, arc0, idsCgPnt, nameCmd, offHs, offVs);

                break;

                #endregion "R"

                #region "P"

            case "P":
                prompt     = "S\nelect Begin Curve backsight Cogo Point for grade and direction: ";
                pnt3dBegBS = UserInput.getPoint(prompt, pnt3dBeg, out escape, out ps, osMode: 8);
                if (pnt3dBegBS == Pub.pnt3dO)
                {
                    return;
                }

                prompt     = "\nSelect Cogo Point for end elevation: ";
                idCgPntEnd = getEndPoint(pnt3dBeg, out elev, prompt);
                if (elev == "")
                {
                    return;
                }
                pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();

                grd = (pnt3dEnd.Z - pnt3dBeg.Z) / arc0.Length;
                BaseObjs.write(string.Format("\nSlope along curve is: {0:P2}", grd));

                prompt     = "\nSelect End Curve backsight Cogo Point for grade and direction: ";
                pnt3dEndBS = UserInput.getPoint(prompt, pnt3dEnd, out escape, out ps, osMode: 8);
                if (pnt3dEndBS == Pub.pnt3dO)
                {
                    return;
                }

                pnt3dPI = Geom.getPntInt(pnt3dBegBS, pnt3dBeg, pnt3dEndBS, pnt3dEnd, true, extend.both);

                g1 = pnt3dBegBS.getSlope(pnt3dBeg);
                g2 = pnt3dEndBS.getSlope(pnt3dEnd);

                el1 = pnt3dBeg.Z + g1 * pnt3dBeg.getDistance(pnt3dPI);
                el2 = pnt3dEnd.Z + g2 * pnt3dEnd.getDistance(pnt3dPI);

                el = (el1 + el2) / 2;

                pnt3dPI = new Point3d(pnt3dPI.X, pnt3dPI.Y, el);

                pnt3dChordMid = pnt3dBeg.getMidPoint3d(pnt3dEnd);

                v3dM = pnt3dPI - pnt3dChordMid;

                pnts3d = arc0.planeMethod(pnt3dBeg, pnt3dEnd, pnt3dPI, v3dM, ref idsCgPnt, nameCmd);
                idsCgPnt.Add(idCgPntEnd);

                arcInfos = new List <arcInfo>();
                for (int s = 0; s < pnts3d.Count; s++)
                {
                    pnt3dX = pnts3d[s];
                    aInfo  = getArcInfo(pnt3dX, arc0, nameCmd, offHs, offVs, idsCgPnt[s]);
                    arcInfos.Add(aInfo);
                }

                processArcInfo(ref arcInfos);
                processArcs(arcs, arcInfos, arc0, idsCgPnt, nameCmd, offHs, offVs);

                break;

                #endregion "P"
            }
        }