Beispiel #1
0
        getPNT_DATA_FINAL(Alignment objAlignPL, Alignment objAlignRF)
        {
            List <double>   dblStationsFinal = new List <double>();
            List <PNT_DATA> Pnt_Data_PL      = new List <PNT_DATA>();
            PNT_DATA        Pnt_Data         = new PNT_DATA();

            double dblStationRF = 0;

            int i = 0;
            int j = 0;
            int k = 0;
            int n = 0;
            int x = 0;

            //GET PL AND RF PROFILES

            Profile objProfilePL = null;

            try {
                objProfilePL = Prof.getProfile(objAlignPL.Name, "EXIST");
            }
            catch (Autodesk.AutoCAD.Runtime.Exception) {
            }

            if ((objProfilePL == null))
            {
                Application.ShowAlertDialog("EXIST profile for PL missing.  Exiting .....");
                return(null);
            }

            Profile objProfileRF = null;

            try {
                objProfileRF = Prof.getProfile(objAlignRF.Name, "CPNT");
            }
            catch (Autodesk.AutoCAD.Runtime.Exception) {
            }

            if ((objProfileRF == null))
            {
                Application.ShowAlertDialog("CPNT profile for REF Alignment missing.  Exiting .....");
                return(null);
            }

            foreach (ProfilePVI objPVI_PL in objProfilePL.PVIs)
            {
                if (objPVI_PL.Station >= objAlignRF.StartingStation & objPVI_PL.Station <= objAlignRF.EndingStation)
                {
                    Pnt_Data     = new PNT_DATA();
                    Pnt_Data.STA = System.Math.Round(objPVI_PL.Station, 2);
                    Pnt_Data_PL.Add(Pnt_Data);
                }
            }

            // Existing profile PVIs within objAlignRF limits
            double dblLenBack  = 0;
            double dblLenAhead = 0;

            for (i = 1; i < Pnt_Data_PL.Count; i++)
            {
                dblLenBack  = (Pnt_Data_PL[i - 0].STA - Pnt_Data_PL[i - 1].STA);
                dblLenAhead = (Pnt_Data_PL[i + 1].STA - Pnt_Data_PL[i + 0].STA);

                if (dblLenBack != 0)
                {
                    Pnt_Data_PL[i].SLOPEBACK = System.Math.Round((objProfilePL.ElevationAt(Pnt_Data_PL[i - 1].STA) - objProfilePL.ElevationAt(Pnt_Data_PL[i - 0].STA)) / dblLenBack, 5);
                }

                if (dblLenAhead != 0)
                {
                    Pnt_Data_PL[i].SLOPEAHEAD = System.Math.Round((objProfilePL.ElevationAt(Pnt_Data_PL[i + 1].STA) - objProfilePL.ElevationAt(Pnt_Data_PL[i + 0].STA)) / dblLenAhead, 5);
                }
            }

            // CPNT profile pvis
            List <PNT_DATA> Pnt_Data_DE = new List <PNT_DATA>();

            Wall_Form.frmWall2 fWall2 = Wall_Forms.wForms.fWall2; {
                Pnt_Data_DE = fWall2.PNTSDESIGN;

                if ((Pnt_Data_DE == null))
                {
                    Pnt_Data_DE = new List <PNT_DATA>();

                    int z = objProfileRF.PVIs.Count;

                    foreach (ProfilePVI objPVI_RF in objProfileRF.PVIs)
                    {
                        dblStationRF = objPVI_RF.Station;

                        Pnt_Data = new PNT_DATA();
                        if (i == 0)
                        {
                            Pnt_Data.STA = System.Math.Round(dblStationRF + 0.01, 2);
                        }
                        else if (i == z - 1)
                        {
                            Pnt_Data.STA = System.Math.Round(dblStationRF - 0.01, 2);
                        }
                        else
                        {
                            Pnt_Data.STA = System.Math.Round(dblStationRF, 2);
                        }

                        Pnt_Data.z = objPVI_RF.Elevation;

                        Pnt_Data_DE.Add(Pnt_Data);
                    }
                }
                else
                {
                    k = Pnt_Data_DE.Count - 1;

                    for (i = 1; i <= k - 1; i++)
                    {
                        dblLenBack  = (Pnt_Data_DE[i - 0].STA - Pnt_Data_DE[i - 1].STA);
                        dblLenAhead = (Pnt_Data_DE[i + 1].STA - Pnt_Data_DE[i + 0].STA);

                        if (dblLenBack != 0)
                        {
                            Pnt_Data_DE[i].SLOPEBACK = System.Math.Round((objProfileRF.ElevationAt(Pnt_Data_DE[i - 1].STA) - objProfileRF.ElevationAt(Pnt_Data_DE[i - 0].STA)) / dblLenBack, 5);
                        }

                        if (dblLenAhead != 0)
                        {
                            Pnt_Data_DE[i].SLOPEAHEAD = System.Math.Round((objProfileRF.ElevationAt(Pnt_Data_DE[i + 1].STA) - objProfileRF.ElevationAt(Pnt_Data_DE[i + 0].STA)) / dblLenAhead, 5);
                        }
                    }
                }
            }

            double          dblSlopDiff  = 0;
            List <PNT_DATA> Pnt_Data_Tmp = new List <PNT_DATA>();

            if (Pnt_Data_DE.Count > 0)
            {
                Pnt_Data_Tmp.Add(Pnt_Data_DE[0]);
            }

            j = 0;

            for (i = 0; i <= Pnt_Data_PL.Count - 1; i++)
            {
                dblSlopDiff = Pnt_Data_PL[i].SLOPEAHEAD - Pnt_Data_PL[i].SLOPEBACK;

                if (System.Math.Abs(System.Math.Round(dblSlopDiff, 2)) > 0.005)
                {
                    Pnt_Data_Tmp.Add(Pnt_Data_PL[i]);
                }
            }

            for (i = 1; i <= Pnt_Data_DE.Count - 1; i++)
            {
                dblSlopDiff = Pnt_Data_DE[i].SLOPEAHEAD + Pnt_Data_DE[i].SLOPEBACK;

                if (System.Math.Round(dblSlopDiff, 2) > 0.001)
                {
                    Pnt_Data_Tmp.Add(Pnt_Data_DE[i]);
                }
            }

            if (Pnt_Data_DE.Count > 1)
            {
                Pnt_Data_Tmp.Add(Pnt_Data_DE[Pnt_Data_DE.Count - 1]);
            }

            dynamic staPNT_DATA = from data in Pnt_Data_Tmp
                                  orderby data.STA
                                  select data;

            i = -1;
            foreach (PNT_DATA vPNT_DATA in staPNT_DATA)
            {
                i = i + 1;
                Pnt_Data_Tmp[i] = vPNT_DATA;
            }

            List <PNT_DATA> Pnt_Data_Final = new List <PNT_DATA>();

            Pnt_Data_Final.Add(Pnt_Data_Tmp[0]);

            k = Pnt_Data_Tmp.Count - 1;
            j = 0;
            //GET GRADEBREAKS
            for (i = 1; i <= k; i++)
            {
                dblLenBack = System.Math.Round(Pnt_Data_Tmp[i - 0].STA - Pnt_Data_Tmp[i - 1].STA, 1);

                if (Pnt_Data_Tmp[i].SLOPEBACK < 0)
                {
                    if (Pnt_Data_Tmp[i].SLOPEAHEAD < 0)
                    {
                        Pnt_Data_Final.Add(Pnt_Data_Tmp[i]);
                    }
                }
                else if (Pnt_Data_Tmp[i].SLOPEBACK > 0)
                {
                    if (Pnt_Data_Tmp[i].SLOPEAHEAD > 0)
                    {
                        Pnt_Data_Final.Add(Pnt_Data_Tmp[i]);
                    }
                }
            }

            int intInterval = 10;

            //ADD DATAPOINTS EVERY intInterval  FEET
            for (i = 1; i < Pnt_Data_Tmp.Count; i++)
            {
                dblLenBack = System.Math.Round(Pnt_Data_Tmp[i - 0].STA - Pnt_Data_Tmp[i - 1].STA, 1);

                if (dblLenBack > intInterval)
                {
                    n = (int)System.Math.Truncate(dblLenBack / intInterval);

                    if (i == 1)
                    {
                        for (x = 1; x <= n; x++)
                        {
                            Pnt_Data     = new PNT_DATA();
                            Pnt_Data.STA = Pnt_Data_Tmp[i - 1].STA + x * intInterval;
                            Pnt_Data_Final.Add(Pnt_Data);
                        }
                    }
                    else
                    {
                        if (dblLenBack / intInterval - n < 0.2)
                        {
                            Pnt_Data = new PNT_DATA();
                            Pnt_Data_Final.Add(Pnt_Data_Tmp[i - 1]);

                            Pnt_Data     = new PNT_DATA();
                            Pnt_Data.STA = Pnt_Data_Tmp[i - 1].STA + dblLenBack / (n + 1);
                            Pnt_Data_Final.Add(Pnt_Data);
                        }
                        else
                        {
                            for (x = 0; x <= n; x++)
                            {
                                Pnt_Data     = new PNT_DATA();
                                Pnt_Data.STA = Pnt_Data_Tmp[i - 1].STA + x * intInterval;
                                Pnt_Data_Final.Add(Pnt_Data);
                            }
                        }
                    }
                }
                else if (dblLenBack > 5)
                {
                    Pnt_Data_Final.Add(Pnt_Data_Tmp[i]);
                }
            }

            j = Pnt_Data_Final.Count - 1;

            if (objAlignRF.EndingStation - Pnt_Data_Final[j].STA > 5)
            {
                Pnt_Data_Final.Add(Pnt_Data_Tmp[k]);
            }
            else
            {
                Pnt_Data_Final[j] = Pnt_Data_Tmp[k];
            }

            for (i = 0; i <= Pnt_Data_Final.Count - 1; i++)
            {
                if (Pnt_Data_Final[i].STA < Pnt_Data_PL[0].STA)
                {
                    Pnt_Data_Final[i] = Pnt_Data_PL[0];
                }
                else
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
            }

            if (Pnt_Data_DE.Count > 1)
            {
                Pnt_Data_Final.Add(Pnt_Data_DE[Pnt_Data_DE.Count - 1]);
            }

            staPNT_DATA = from data in Pnt_Data_Final
                          orderby data.STA
                          select data;

            Pnt_Data_Tmp = new List <PNT_DATA>();

            foreach (PNT_DATA vPNT_DATA in staPNT_DATA)
            {
                vPNT_DATA.STA = System.Math.Round(vPNT_DATA.STA, 1);
                Pnt_Data_Tmp.Add(vPNT_DATA);
            }

            Pnt_Data_Final = new List <PNT_DATA>();

            Pnt_Data_Final = Misc.removeDuplicateStations(Pnt_Data_Tmp);

            dblStationsFinal = new List <double>();

            for (i = 0; i < Pnt_Data_Final.Count; i++)
            {
                dblStationsFinal.Add(Pnt_Data_Final[i].STA);
            }

            return(dblStationsFinal);
        }
Beispiel #2
0
        addLeader(Point3d varPntIns, string varPntNum, string strLayer, string strProfile, int shtScale, double dblScaleProfileView, object varDesc = null)
        {
            Point3dCollection pnts3dLdr = new Point3dCollection();
            Point3d           pnt3d     = Pub.pnt3dO;

            pnts3dLdr.Add(varPntIns);
            pnt3d = new Point3d(varPntIns.X + 4, varPntIns.Y - 4, 0);
            pnts3dLdr.Add(pnt3d);

            string strDesc = varPntNum;

            int      intStrLen  = strDesc.Length;
            ObjectId idTxtStyle = ObjectId.Null;

            try
            {
                idTxtStyle = Txt.getTextStyleId("Annotative");
            }
            catch (Exception)
            {
                idTxtStyle = Txt.getTextStyleId("Standard");
            }

            ObjectId idDimStyle = ObjectId.Null;

            try
            {
                idDimStyle = Dim.getDimStyleTableRecord("Annotative");
            }
            catch (Exception)
            {
                idDimStyle = Dim.getDimStyleTableRecord("Standard");
            }

            short intColor = 256;

            if (strProfile == "EXIST")
            {
                intColor = 1;
            }
            else
            {
                intColor = 4;
            }
            Wall_Form.frmWall2 fWall2 = Wall_Forms.wForms.fWall2;
            MText    mTxt             = null;
            ObjectId idMtext          = ObjectId.Null;

            try
            {
                idMtext = Txt.addMText(strDesc, pnt3d, 0, 0);

                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    mTxt             = (MText)tr.GetObject(idMtext, OpenMode.ForWrite);
                    mTxt.Attachment  = AttachmentPoint.BottomLeft;
                    mTxt.Layer       = strLayer;
                    mTxt.Color       = Color.FromColorIndex(ColorMethod.ByBlock, (short)intColor);
                    mTxt.TextStyleId = idTxtStyle;

                    MText          objLabel   = fWall2.LABEL;
                    List <Point3d> varPntsInt = mTxt.intersectWith(objLabel, false, extend.none);

                    if (varPntsInt.Count > 0)
                    {
                        Point3d pnt3dX = new Point3d(pnt3d.X - 0.35 * dblScaleProfileView, pnt3d.Y, 0);
                        mTxt.Location = pnt3dX;
                    }
                    fWall2.LABEL = mTxt;

                    tr.Commit();
                }
            }
            catch (Exception)
            {
            }

            ObjectId idLayer  = Layer.manageLayers(strLayer);
            ObjectId idLeader = Ldr.addLdr(pnts3dLdr, idLayer, 0.09, 0, clr.byl, idMtext);
            Leader   ldr      = null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                ldr                = (Leader)tr.GetObject(idLeader, OpenMode.ForWrite);
                ldr.Dimasz         = 0.09;
                ldr.HasArrowHead   = true;
                ldr.Dimgap         = 0.01;
                ldr.DimensionStyle = idDimStyle;

                tr.Commit();
            }

            TypedValue[] tvs = new TypedValue[] { new TypedValue(1001, "LEADER"), new TypedValue(1005, ldr.Handle) };
            idMtext.setXData(tvs, "LEADER");
            return(true);
        }