Beispiel #1
0
        getElev(Point3d pnt3dInt, ObjectId id3dBoundary)
        {
            double         dblElev = 0;
            List <Point3d> pnts3d  = id3dBoundary.getCoordinates3dList();

            for (int i = 0; i < pnts3d.Count; i++)
            {
                if (Math.roundDown2(pnt3dInt.X) == Math.roundDown2(pnts3d[i].X) &&
                    Math.roundDown2(pnt3dInt.Y) == Math.roundDown2(pnts3d[i].Y))
                {
                    dblElev = pnts3d[i].Z;
                    break;
                }
            }
            return(dblElev);
        }
Beispiel #2
0
        getBldgElev(ObjectId idAlign, ref List <POI> varpoi)
        {
            ResultBuffer rb = idAlign.getXData("BLDG");

            if (rb == null)
            {
                return;
            }
            TypedValue[] tvs = rb.AsArray();

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

            double dblAngTar = double.Parse(tvs[4].Value.ToString());
            double dblSlope  = double.Parse(tvs[5].Value.ToString());

            Point3d pnt3dTar = pnt3dCen.traverse(dblAngTar, 100, dblSlope);

            Debug.Print("BEGIN GET BLDG ELEV");
            double    dblEasting = 0, dblNorthing = 0;
            Alignment objAlign = (Alignment)idAlign.getEnt();

            for (int i = 0; i < varpoi.Count; i++)
            {
                objAlign.PointLocation(varpoi[i].Station, varpoi[i].OFFSET, ref dblEasting, ref dblNorthing);
                Point3d pnt3dX = new Point3d(dblEasting, dblNorthing, 0);
                double  elev   = pnt3dTar.Z + Geom.getCosineComponent(pnt3dCen, pnt3dTar, pnt3dX) * (dblSlope * -1);
                pnt3dX = pnt3dX.addElevation(elev);
                POI vpoi = varpoi[i];
                vpoi.Elevation = Math.roundDown2(pnt3dX.Z);
                varpoi[i]      = vpoi;

                Debug.Print(varpoi[i].Station + " " + varpoi[i].Elevation + " " + varpoi[i].Desc0);
            }

            Debug.Print("END GET BLDG ELEV");
        }
Beispiel #3
0
        getSurfaceElev(double dblX, double dblY, TinSurface objSurface)
        {
            double dblElev = 0;
            double dblXX   = 0;
            double dblYY   = 0;

            dblElev = objSurface.FindElevationAtXY(dblX, dblY);

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

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

            return(dblElev);
        }
Beispiel #4
0
        resolveDuplicateStationsGrid(List <POI> varpoi)
        {
            //BEGIN RESOLVE DUPLICATE STATIONS GRID

            List <POI> varPOI_LIM = new List <POI>();
            List <POI> varPOI_IN  = new List <POI>();
            int        k          = -1;

            for (int i = 0; i < varpoi.Count; i++)
            {
                if (varpoi[i].OFFSET == 0)
                {
                    varPOI_LIM.Add(varpoi[i]);
                }
                else
                {
                    varPOI_IN.Add(varpoi[i]);
                    k++;
                }
            }

            Debug.Print("BEGIN RESOLVE DUPLICATE STATIONS GRID");

            int        j           = -1;
            List <POI> varPOI_Temp = new List <POI>();

            varPOI_Temp.Add(varPOI_LIM[0]);
            j++;

            Debug.Print("0" + " " + varPOI_Temp[0].Station + " " + varPOI_Temp[0].Elevation + " " + varPOI_Temp[0].Desc0 + "   " + varPOI_Temp[0].DescX);

            for (int i = 1; i < varPOI_LIM.Count; i++)
            {
                if (System.Math.Abs(Math.roundDown2(varPOI_LIM[i - 1].Station) - Math.roundDown2(varPOI_LIM[i - 0].Station)) > 0.1)
                {
                    varPOI_Temp.Add(varPOI_LIM[i - 0]);
                    j++;
                }
                else if (varPOI_LIM[i - 1].Desc0.Substring(0, 2) == "AP")
                {
                    varPOI_LIM[i - 1].DescX = varPOI_LIM[i - 0].DescX;
                    varPOI_Temp[j]          = varPOI_LIM[i - 1];
                }
                else if (varPOI_LIM[i - 0].Desc0.Substring(0, 2) == "AP")
                {
                    varPOI_LIM[i - 0].DescX = varPOI_LIM[i - 1].DescX;
                    varPOI_Temp[j]          = varPOI_LIM[i - 0];
                }

                Debug.Print(j + " " + varPOI_Temp[j].Station + " " + varPOI_Temp[j].Elevation + " " + varPOI_Temp[j].Desc0 + "   " + varPOI_Temp[j].DescX);
            }

            varPOI_Temp[j].DescX = varPOI_Temp[0].DescX;

            varpoi = new List <POI>();

            for (int i = 0; i <= j; i++)
            {
                varpoi.Add(varPOI_Temp[i]);
            }

            for (int i = j + 1; i <= j + k + 1; i++)
            {
                varpoi[i] = varPOI_IN[i - j - 1];
            }

            Debug.Print("END RESOLVE DUPLICATE STATIONS GRID");
            //END RESOLVE DUPLICATE STATIONS GRID
        }
Beispiel #5
0
        resolveDuplicateStationsWall(ref List <POI> varpoi)
        {
            List <POI> varPOI_IN = null;

            //BEGIN RESOLVE DUPLICATE STATIONS WALL

            int        j           = -1;
            List <POI> varPOI_Temp = null;

            varPOI_Temp.Add(varpoi[0]);
            j++;

            int k = -1;

            Debug.Print("BEGIN RESOLVE DUPLICATE STATIONS WALL");
            Debug.Print("0" + " " + varpoi[0].Station + " " + varpoi[0].Elevation + " " + varpoi[0].Desc0 + "   " + varpoi[0].DescX);

            for (int i = 1; i < varpoi.Count; i++)
            {
                if (System.Math.Abs(Math.roundDown2(varpoi[i - 1].Station) - Math.roundDown2(varpoi[i - 0].Station)) > 0.1)
                {
                    varPOI_Temp.Add(varpoi[i - 0]);
                    j++;
                }
                else
                {
                    string strDescPrev = varpoi[i - 1].Desc0.Substring(0, 2);
                    string strDescCurr = varpoi[i - 0].Desc0.Substring(0, 2);

                    switch (strDescPrev)
                    {
                    case "HC":
                        switch (strDescCurr)
                        {
                        case "BE":
                        case "EN":

                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0;
                            varPOI_Temp[j]      = varpoi[i - 0];

                            break;

                        case "AP":

                            varpoi[i - 0].DescX = varpoi[i - 1].DescX;
                            varPOI_Temp[j]      = varpoi[i - 0];

                            break;

                        default:

                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0;
                            varPOI_Temp[j]      = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "AP":

                        switch (strDescCurr)
                        {
                        case "TOF":

                            varpoi[i - 1].DescX     = varpoi[i - 1].Desc0 + " " + varpoi[i - 0].Desc0;
                            varpoi[i - 1].Elevation = varpoi[i - 0].Elevation;
                            varPOI_Temp[j]          = varpoi[i - 1];

                            break;

                        case "TOW":

                            varpoi[i - 1].DescX = varpoi[i - 0].DescX;
                            varPOI_Temp[j]      = varpoi[i - 1];

                            break;
                        }

                        break;

                    case "TOF":

                        switch (strDescCurr)
                        {
                        case "AP":

                            varpoi[i - 1].DescX = varpoi[i - 0].DescX;
                            varPOI_Temp[j]      = varpoi[i - 1];

                            break;

                        case "TOW":

                            varpoi[i - 1].DescX = varpoi[i - 0].DescX;
                            varPOI_Temp[j]      = varpoi[i - 1];

                            break;
                        }

                        break;

                    case "TOW":

                        switch (strDescCurr)
                        {
                        case "AP":

                            varpoi[i - 1].DescX = varpoi[i - 0].DescX;
                            varPOI_Temp[j]      = varpoi[i - 1];

                            break;

                        case "TOF":

                            varpoi[i - 1].DescX = varpoi[i - 0].DescX;
                            varPOI_Temp[j]      = varpoi[i - 1];

                            break;
                        }

                        break;
                    }

                    Debug.Print(j + " " + varPOI_Temp[j].Station + " " + varPOI_Temp[j].Elevation + " " + varPOI_Temp[j].Desc0 + "   " + varPOI_Temp[j].DescX);
                }
            }

            varPOI_Temp[j].DescX = varPOI_Temp[0].DescX;

            varpoi = new List <POI>();

            for (int i = 0; i <= j; i++)
            {
                varpoi.Add(varPOI_Temp[i]);
            }

            for (int i = j + 1; i <= j + k + 1; i++)
            {
                varpoi.Add(varPOI_IN[i - j - 1]);
            }

            Debug.Print("END RESOLVE DUPLICATE STATIONS WALL");
            //END RESOLVE DUPLICATE STATIONS WALL
        }
Beispiel #6
0
        resolveDuplicateStations(ref List <POI> varpoi)
        {
            var sortSta = from p in varpoi
                          orderby p.Station ascending
                          select p;

            List <POI> poiTmp = new List <POI>();

            foreach (var p in sortSta)
            {
                poiTmp.Add(p);
            }

            varpoi = poiTmp;

            //BEGIN RESOLVE DUPLICATE STATIONS
            Debug.Print("BEGIN RESOLVE DUPLICATE STATIONS");

            int        j           = -1;
            List <POI> varPOI_Temp = new List <POI>();

            varPOI_Temp.Add(varpoi[0]);
            j++;

            Debug.Print("0" + " " + varpoi[0].Station + " " + varpoi[0].Elevation + " " + varpoi[0].Desc0 + "   " + varpoi[0].DescX);
            string strDesc = ""; int intLen = 0;

            for (int i = 1; i < varpoi.Count; i++)
            {
                if (System.Math.Abs(Math.roundDown2(varpoi[i - 1].Station) - Math.roundDown2(varpoi[i - 0].Station)) > 0.1)
                {
                    if (varpoi[i - 0].Desc0.Substring(0, 2) != "HE")
                    {
                        string descx = string.Format("{0} {1}", varpoi[i - 0].Desc0, varpoi[i - 0].DescX.Replace("HC", "").Trim());
                        varpoi[i - 0].DescX = descx;
                    }

                    varPOI_Temp.Add(varpoi[i - 0]);
                    j++;
                }
                else
                {
                    switch (varpoi[i - 1].Desc0.Substring(0, 2)) //(i-1) PREVIOUS
                    {
                    case "AP":                                   //(i-1) PREVIOUS
                        switch (varpoi[i - 0].Desc0)
                        {
                        case "TEE":        //(i-0) CURRENT
                            varpoi[i - 1].DescX = "AP/TEE";
                            varPOI_Temp[j]      = varpoi[i - 1];
                            break;

                        case "BEG":
                        case "END":        //(i-0) CURRENT
                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0;
                            varPOI_Temp[j]      = varpoi[i - 0];
                            break;

                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            //CHECK NEXT
                            varpoi[i - 0].DescX       = varpoi[i - 1].Desc0 + " " + varpoi[i - 0].Desc0;
                            varpoi[i - 0].Desc0       = varpoi[i - 1].Desc0;
                            varpoi[i - 0].AngDelta    = varpoi[i - 1].AngDelta;
                            varpoi[i - 0].AngDir      = varpoi[i - 1].AngDir;
                            varpoi[i - 0].isRightHand = varpoi[i - 1].isRightHand;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "BE":    //BEG         '(i-1) PREVIOUS

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "TEE":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = "BEG/TEE";
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;
                            varPOI_Temp[j]         = varpoi[i - 0];

                            break;

                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 1].Desc0 + " " + varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;
                            varPOI_Temp[j]         = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "BC":    //(i-1) PREVIOUS

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX     = varpoi[i - 1].Desc0 + " " + varpoi[i - 0].Desc0;
                            varpoi[i - 0].Desc0     = varpoi[i - 1].Desc0;
                            varpoi[i - 0].Radius    = varpoi[i - 1].Radius;
                            varpoi[i - 0].CenterPnt = varpoi[i - 1].CenterPnt;
                            varPOI_Temp[j]          = varpoi[i - 0];
                            break;
                        }

                        break;

                    case "EC":    //(i-1) PREVIOUS

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX = varpoi[i - 1].Desc0 + " " + varpoi[i - 0].Desc0;
                            varpoi[i - 0].Desc0 = varpoi[i - 1].Desc0;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;

                        case "BC":        //(i-0) CURRENT

                            switch (varpoi[i - 1].isRightHand)
                            {
                            case true:

                                switch (varpoi[i - 0].isRightHand)
                                {
                                case true:

                                    strDesc             = varpoi[i - 1].DescX;
                                    intLen              = strDesc.Length;
                                    varpoi[i - 0].DescX = strDesc.Substring(0, intLen - 2) + "/PCC";

                                    break;

                                case false:

                                    strDesc             = varpoi[i - 1].DescX;
                                    intLen              = strDesc.Length;
                                    varpoi[i - 0].DescX = strDesc.Substring(0, intLen - 2) + "/PRC";

                                    break;
                                }

                                break;

                            case false:

                                switch (varpoi[i - 0].isRightHand)
                                {
                                case true:

                                    strDesc             = varpoi[i - 1].DescX;
                                    intLen              = strDesc.Length;
                                    varpoi[i - 0].DescX = strDesc.Substring(0, intLen - 2) + "/PRC";

                                    break;

                                case false:

                                    strDesc             = varpoi[i - 1].DescX;
                                    intLen              = strDesc.Length;
                                    varpoi[i - 0].DescX = strDesc.Substring(0, intLen - 2) + " PCC";

                                    break;
                                }

                                break;
                            }

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "GB":    //(i-1) PREVIOUS     "GB LP", "GB HP" is covered

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "BC":
                            varpoi[i - 1].DescX       = varpoi[i - 0].Desc0 + " " + varpoi[i - 1].Desc0;
                            varpoi[i - 1].Desc0       = varpoi[i - 0].Desc0;
                            varpoi[i - 1].Radius      = varpoi[i - 0].Radius;
                            varpoi[i - 1].isRightHand = varpoi[i - 0].isRightHand;
                            varpoi[i - 1].CenterPnt   = varpoi[i - 0].CenterPnt;
                            varPOI_Temp[j]            = varpoi[i - 1];

                            break;

                        case "EC":        //(i-0) CURRENT
                            varpoi[i - 1].DescX = varpoi[i - 0].Desc0 + " " + varpoi[i - 1].Desc0;
                            varpoi[i - 1].Desc0 = varpoi[i - 0].Desc0;
                            varPOI_Temp[j]      = varpoi[i - 1];
                            break;

                        case "AP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0 + " " + varpoi[i - 1].Desc0;
                            varPOI_Temp[j]      = varpoi[i - 0];
                            break;
                        }
                        break;

                    case "HC":    //(i-1) PREVIOUS HORIZONTAL CONTROL

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "AP":        //(i-0) CURRENT
                            string descX = string.Format("{0} {1}", varpoi[i - 0].Desc0, varpoi[i - 1].DescX.Replace("HC", "").Trim());
                            varpoi[i - 0].DescX = descX;
                            varPOI_Temp[j]      = varpoi[i - 0];

                            break;

                        case "BEG":
                        case "END":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;
                            varPOI_Temp[j]         = varpoi[i - 0];

                            break;

                        case "BC":
                        case "EC":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;
                            varPOI_Temp[j]         = varpoi[i - 0];

                            break;

                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;
                            varPOI_Temp[j]         = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "HE":
                    case "H0":    //(i-1) PREVIOUS   HORIZONTAL CONTROL WITH INTERPOLATED ELEVATION

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "AP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;

                        case "BEG":
                        case "END":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;

                        case "BC":
                        case "EC":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0 + " " + varpoi[i - 1].DescX.Replace("HE", "").Trim();
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;

                        case "GB":
                        case "GB LP":
                        case "GB HP":        //(i-0) CURRENT

                            varpoi[i - 0].DescX    = varpoi[i - 0].Desc0;
                            varpoi[i - 0].isClosed = varpoi[i - 1].isClosed;

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;
                        }

                        break;

                    case "TE":
                        //(i-1) PREVIOUS   TEE

                        switch (varpoi[i - 0].Desc0)
                        {
                        case "AP":
                            //(i-0) CURRENT

                            varpoi[i - 0].DescX = "AP/TEE";

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;

                        case "BEG":
                        case "END":
                            //(i-0) CURRENT

                            varpoi[i - 0].DescX = varpoi[i - 0].Desc0 + "/TEE";

                            varPOI_Temp[j] = varpoi[i - 0];

                            break;
                        }

                        break;

                    default:

                        varpoi[i - 0].DescX = varpoi[i - 0].Desc0;

                        varPOI_Temp[j] = varpoi[i - 0];

                        break;
                    }
                }

                Debug.Print(j + " " + varPOI_Temp[j].Station + " " + varPOI_Temp[j].Elevation + " " + varPOI_Temp[j].Desc0 + "   " + varPOI_Temp[j].DescX);
            }

            varpoi = varPOI_Temp;

            Debug.Print("END RESOLVE DUPLICATE STATIONS");
            //END RESOLVE DUPLICATE STATIONS
        }
Beispiel #7
0
        syncTableWithProfile()
        {
            List <POI> varPOIcur = fStake.POI_CALC;

            Alignment    objAlign = fStake.ACTIVEALIGN;
            ObjectId     idAlign  = objAlign.ObjectId;
            ResultBuffer rb       = idAlign.getXData("CLASS");

            if (rb == null)
            {
                return;
            }

            TypedValue[] tvs = rb.AsArray();
            fStake.ClassObj = tvs[1].Value.ToString();

            Profile objProfile = null;

            try
            {
                objProfile = Prof.getProfile(idAlign, "STAKE");
            }
            catch (System.Exception)
            {
            }

            ProfilePVICollection objProfilePVIs = objProfile.PVIs;
            Table    objTable = null;
            ObjectId idTable  = ObjectId.Null;

            try
            {
                idTable = Stake_Table.getTableId(idAlign);
            }
            catch (System.Exception)
            {
                try
                {
                    SelectionSet ss  = Select.buildSSet(typeof(Table));
                    ObjectId[]   ids = ss.GetObjectIds();

                    if (ids.Length > 0)
                    {
                        for (int i = 0; i < ids.Length; i++)
                        {
                            idTable  = ids[i];
                            objTable = (Table)idTable.getEnt();
                            if (objTable.Cells[1, 1].TextString == objAlign.Name)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (System.Exception)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Select Table Failed");
                    return;
                }
            }

            fStake.POI_CALC = resetPOI(idTable);
            List <POI> varPOITmp = fStake.POI_CALC;

            List <POI> varpoi    = new List <POI>();
            List <POI> varpoiAdd = new List <POI>();

            Debug.Print(varPOITmp.Count.ToString());
            ProfilePVI objProfilePVI = null;

            for (int i = 0; i < varPOITmp.Count; i++)
            {
                for (int j = 0; j < objProfilePVIs.Count; j++)
                {
                    objProfilePVI = objProfilePVIs[j];
                    if (Math.roundDown2((objProfilePVI.Station)) == Math.roundDown2(varPOITmp[i].Station))
                    {
                        varpoi.Add(varPOITmp[i]);
                        break;
                    }
                }
            }
            bool boolExists = false;

            for (int i = 0; i < objProfilePVIs.Count; i++)
            {
                boolExists    = false;
                objProfilePVI = objProfilePVIs[i];
                for (int j = 0; j < varpoi.Count; j++)
                {
                    if (Math.roundDown2(varpoi[j].Station) == Math.roundDown2((objProfilePVI.Station)))
                    {
                        boolExists = true;
                        break;
                    }
                }

                if (!boolExists)
                {
                    POI vpoi = new POI();
                    vpoi.Station   = Math.roundDown3((objProfilePVI.Station));
                    vpoi.Elevation = objProfilePVI.Elevation;
                    vpoi.ClassObj  = fStake.ClassObj;
                    vpoi.Desc0     = "GB";
                    varpoiAdd.Add(vpoi);
                }
            }

            if (varpoiAdd[0].Desc0 != "NOTHING")
            {
                for (int i = 0; i < varpoiAdd.Count; i++)
                {
                    varpoi.Add(varpoiAdd[i]);
                }
            }

            var sortSta = from p in varpoi
                          orderby p.Station ascending
                          select p;

            List <POI> poiTmp = new List <POI>();

            foreach (var p in sortSta)
            {
                poiTmp.Add(p);
            }

            varpoi = poiTmp;

            updateTableData(idTable, varpoi);

            fStake.POI_CALC = varpoi;
        }
Beispiel #8
0
        Create_Align_Profile_By3dPoly2b2c(Alignment objAlignPL, string strName, string strNameAlign, ObjectId idLayer, ObjectId idPoly3dRF)
        {
            bool boolBeg = false;
            bool boolEnd = false;

            ObjectId idProfileStyle  = Prof_Style.getProfileStyle("WALL");
            ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL");
            //ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard");
            //ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard");

            List <Point3d> pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList();

            ObjectId idPoly2dRF = idPoly3dRF.toPolyline(idPoly3dRF.getLayer());
            Point3d  pnt3dBegRF = idPoly2dRF.getBegPnt();
            Point3d  pnt3dEndRF = idPoly2dRF.getEndPnt();

            double easting = 0, northing = 0;

            objAlignPL.PointLocation(objAlignPL.StartingStation, 0.0, ref easting, ref northing);
            Point3d pnt3dBegWALL = new Point3d(easting, northing, 0);

            objAlignPL.PointLocation(Math.roundDown2(objAlignPL.EndingStation), 0.0, ref easting, ref northing);
            Point3d pnt3dEndWALL = new Point3d(easting, northing, 0);

            List <Point3d> pnts3d = new List <Point3d> {
                pnt3dBegWALL, pnt3dEndWALL
            };

            double dblAngle = 0;

            dblAngle = pnt3dBegWALL.getDirection(pnt3dEndWALL);

            double dblDistBeg = 0;

            dblDistBeg = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dBegRF);

            double dblDistEnd = 0;

            dblDistEnd = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dEndRF);
            double dblStaBegRef = 0, dblOffBegRef = 0;

            if (dblDistBeg > dblDistEnd)
            {
                idPoly2dRF.reversePolyX();

                pnt3dBegRF = idPoly2dRF.getBegPnt();
                pnt3dEndRF = idPoly2dRF.getEndPnt();

                dblDistBeg = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dBegRF);
                dblDistEnd = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dEndRF);
            }


            if (dblDistBeg < 0)
            {
                boolBeg      = true;
                pnt3dBegWALL = Math.traverse(pnt3dBegWALL, dblAngle - PI, dblDistBeg * -1 + 10);
                pnts3d.Insert(0, pnt3dBegWALL);
            }


            if (dblDistEnd > objAlignPL.Length + 10)
            {
                boolEnd      = true;
                pnt3dEndWALL = Math.traverse(pnt3dEndWALL, dblAngle, objAlignPL.Length - dblDistEnd + 10);
                pnts3d.Add(pnt3dEndWALL);
            }

            Profile objProfile = null;

            string strAlignName = objAlignPL.Name;
            string strLayer     = objAlignPL.Layer;

            idLayer = Layer.manageLayers(strLayer);


            if (boolBeg || boolEnd)
            {
                Align.removeAlignment(strAlignName);
                ObjectId idPoly2dWALL = Draw.addPoly(pnts3d, strLayer);

                objAlignPL = Align.addAlignmentFromPoly(strAlignName, strLayer, idPoly2dWALL, "Standard", "Standard", true);

                try
                {
                    objAlignPL.StationOffset(pnt3dBegRF.X, pnt3dBegRF.Y, ref dblStaBegRef, ref dblOffBegRef);
                }
                catch (Autodesk.Civil.PointNotOnEntityException)
                {
                    dblStaBegRef = 0.0;
                }

                objAlignPL.PointLocation(dblStaBegRef, 0.0, ref easting, ref northing);

                Point2d pnt2dRef = new Point2d(easting, northing);
                objAlignPL.ReferencePoint = pnt2dRef;

                fWall1.ACTIVEALIGN = objAlignPL;

                bool       exists          = false;
                TinSurface objSurfaceEXIST = Surf.getTinSurface("EXIST", out exists);

                ObjectId idAlignStyle         = Align_Style.getAlignmentStyle("Standard");
                ObjectId idAlignLabelSetStyle = Align_Style.getAlignmentLabelSetStyle("Standard");

                using (BaseObjs._acadDoc.LockDocument())
                {
                    using (Transaction TR = BaseObjs.startTransactionDb())
                    {
                        objProfile = Prof.addProfileBySurface("EXIST", objAlignPL.ObjectId, objSurfaceEXIST.ObjectId, idLayer, idProfileStyle, idStyleLabelSet);

                        TR.Commit();
                    }
                }
            }

            Alignment objAlignRF = Align.addAlignmentFromPoly(strNameAlign, strLayer, idPoly2dRF, "Standard", "Standard", true);

            objAlignRF.ReferencePointStation = 1000.0;

            double   dblStation = 0;
            double   dblOffset  = 0;
            ObjectId idAlignRF  = ObjectId.Null;

            try
            {
                idAlignRF.getAlignStaOffset(pnt3dsPoly3d[0], ref dblStation, ref dblOffset);
            }
            catch (Autodesk.Civil.PointNotOnEntityException)
            {
                dblStation = 0.0;
            }


            if (dblStation != objAlignRF.StartingStation)
            {
                idPoly3dRF.reversePolyX();
                pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList();
            }

            using (BaseObjs._acadDoc.LockDocument())
            {
                using (Transaction TR = BaseObjs.startTransactionDb())
                {
                    objProfile = Prof.addProfileByLayout(strName, objAlignRF.ObjectId, idLayer, idProfileStyle, idStyleLabelSet);

                    double dblElev = 0;


                    for (short i = 0; i <= pnt3dsPoly3d.Count - 1; i++)
                    {
                        try
                        {
                            idAlignRF.getAlignStaOffset(pnt3dsPoly3d[i], ref dblStation, ref dblOffset);
                        }
                        catch (Autodesk.Civil.PointNotOnEntityException)
                        {
                            dblStation = 0.0;
                        }
                        dblElev = pnt3dsPoly3d[i].Z;

                        objProfile.PVIs.AddPVI(dblStation, dblElev);
                    }

                    TR.Commit();
                }
            }

            return(idAlignRF);
        }