Beispiel #1
0
        poly3dFromAlignProfile()
        {
            double dblStation = 0;

            double dblX = 0;
            double dblY = 0;
            double dblZ = 0;

            int j = 0;

            List <Point3d> pnts3d  = new List <Point3d>();
            Alignment      align   = Align.getAlignment("RIVER-CL");
            Profile        profile = Prof.getProfile(align.ObjectId, "0");

            for (j = 0; j <= profile.PVIs.Count - 1; j++)
            {
                ProfilePVI profilePVI = profile.PVIs[j];
                dblStation = profilePVI.Station;
                dblZ       = profilePVI.Elevation;

                align.PointLocation(dblStation, 0.0, ref dblX, ref dblY);
                pnts3d.Add(new Point3d(dblX, dblY, dblZ));
            }

            pnts3d.addPoly3d();
        }
Beispiel #2
0
        getPVI(ObjectId idAlign, double dblStation, ref List <POI> varpoi, double dblHeightCurb, ref bool boolNewPVI)
        {
            bool boolFound = false;

            Profile objProfileFLOWLINE          = Prof.getProfile(idAlign, "FLOWLINE");
            Profile objProfileSTAKE             = Prof.getProfile(idAlign, "STAKE");
            ProfilePVICollection objProfilePVIs = objProfileSTAKE.PVIs;

            double dblProfileElev = System.Math.Round(objProfileFLOWLINE.ElevationAt(dblStation) + dblHeightCurb / 12, 3);

            for (int i = 0; i <= objProfilePVIs.Count - 1; i++)
            {
                ProfilePVI objProfilePVI = objProfilePVIs[i];

                if (Math.roundDown1((objProfilePVI.Station)) == Math.roundDown1(dblStation))
                {
                    objProfilePVI.Elevation = dblProfileElev;
                    boolFound = true;

                    break;
                }
            }

            if (boolFound)
            {
                for (int k = 0; k < varpoi.Count; k++)
                {
                    if (varpoi[k].Station == Math.roundDown3(dblStation))
                    {
                        check4GradeBreak(k, varpoi);
                    }
                }

                boolFound = false;
            }
            else
            {
                boolNewPVI = true;
                ProfilePVI objProfilePVI = objProfilePVIs.AddPVI(dblStation, dblProfileElev);

                varpoi.Add(new POI {
                    Station = Math.roundDown3(dblStation), Elevation = dblProfileElev, ClassObj = fStake.ClassObj
                });

                var sortSta = from p in varpoi
                              orderby p.Station
                              select p;
                int j = 0;
                foreach (var p in sortSta)
                {
                    j += 1;
                    if (Math.roundDown3(dblStation) == p.Station)
                    {
                        check4GradeBreak(j, varpoi);
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        addEndElev(ObjectId idAlign, ref List <POI> varpoi, string strBaseProfileName)
        {
            Profile    objProfile    = default(Profile);
            ProfilePVI objProfilePVI = default(ProfilePVI);
            int        j             = varpoi.Count - 1;

            switch (strBaseProfileName)
            {
            case "FLOWLINE":

                objProfile = Prof.getProfile(idAlign, "STAKE");

                try
                {
                    objProfilePVI = objProfile.PVIs.AddPVI(varpoi[j].Station, varpoi[j].Elevation + double.Parse(fStake.cboHeight.Text) / 12);
                }
                catch (System.Exception)
                {
                }

                break;

            case "CPNT":

                objProfile    = Prof.getProfile(idAlign, "CPNT");
                objProfilePVI = objProfile.PVIs.AddPVI(varpoi[j].Station, varpoi[j].Elevation);

                break;

            default:

                objProfilePVI = null;
                objProfile    = Prof.getProfile(idAlign, strBaseProfileName);

                try
                {
                    objProfilePVI = objProfile.PVIs.AddPVI(varpoi[j].Station, varpoi[j].Elevation);
                }
                catch (System.Exception)
                {
                }

                break;
            }
        }
Beispiel #4
0
        private void CreateProfileFromEntities(ProfileEntity pentity, Autodesk.Civil.DatabaseServices.Profile Eprofile,
                                               Autodesk.Civil.DatabaseServices.Profile Nprofile, Point2d startPoint, Point2d endPoint)
        {
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                switch (pentity.EntityType)
                {
                case ProfileEntityType.Tangent:
                    ProfileTangent pTangent = Nprofile.Entities.AddFixedTangent(startPoint, endPoint);
                    break;

                case ProfileEntityType.Circular:
                    ProfileCircular pCircular    = pentity as ProfileCircular;
                    ProfilePVI      pPVI         = Eprofile.PVIs.GetPVIAt(pCircular.PVIStation, pCircular.PVIElevation);
                    double          circleLength = pCircular.Length;
                    ProfileCircular pCircularNew = Nprofile.Entities.AddFreeCircularCurveByPVIAndLength(pPVI, circleLength);
                    break;

                case ProfileEntityType.ParabolaSymmetric:
                    ProfileParabolaSymmetric pParabolaSymetric    = pentity as ProfileParabolaSymmetric;
                    double                   parabolaRadius       = pParabolaSymetric.Radius;
                    VerticalCurveType        vcType               = pParabolaSymetric.CurveType;
                    ProfileParabolaSymmetric pParabolaSymetricNew = Nprofile.Entities.AddFixedSymmetricParabolaByTwoPointsAndRadius(startPoint, endPoint, vcType, parabolaRadius);
                    break;

                case ProfileEntityType.ParabolaAsymmetric:
                    ProfileParabolaAsymmetric pParabolaAsymmetric = pentity as ProfileParabolaAsymmetric;
                    ProfilePVI paPVI    = Eprofile.PVIs.GetPVIAt(pParabolaAsymmetric.PVIStation, pParabolaAsymmetric.PVIElevation);
                    double     pLength1 = pParabolaAsymmetric.AsymmetricLength1;
                    double     pLength2 = pParabolaAsymmetric.AsymmetricLength2;
                    ProfileParabolaAsymmetric pParabolaAsymmetricNew = Nprofile.Entities.AddFreeAsymmetricParabolaByPVIAndLengths(paPVI, pLength1, pLength2);
                    break;

                case ProfileEntityType.None:
                    ProfileTangent nTangent = Nprofile.Entities.AddFixedTangent(startPoint, endPoint);
                    break;
                }

                tr.Commit();
            }
        }
Beispiel #5
0
        CreateProfileBySurface(string strName, ObjectId idAlign, double dblAlignOffset)
        {
            string strAlignName = Align.getAlignName(idAlign);

            //Dim idProfileStyle As ObjectId = Prof_Style.getProfileStyle("WALL")
            //Dim idStyleLabelSet As ObjectId = Prof_Style.getProfileLabelSetStyle("WALL")

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

            string strLayerName = string.Format("PROFILE-{0}", strAlignName);

            Alignment objAlignOff = null;

            if (dblAlignOffset != 0)
            {
                ObjectId idPoly    = Align.getAlignmentPoly(idAlign);
                ObjectId idPolyOff = Base_Tools45.Draw.addPolyOffset(idPoly, dblAlignOffset);

                strAlignName = string.Format("{0}_{1}_OFF", strAlignName, dblAlignOffset);
                objAlignOff  = Align.addAlignmentFromPoly(strAlignName, strLayerName, idPolyOff, "Thienes_Proposed", "Thienes_Proposed", true);
            }

            string strSurface = "";

            if (strName == "CPNT")
            {
                strSurface = "CPNT-ON";
            }
            else
            {
                strSurface = strName;
            }

            TinSurface objSurface = null;

            try
            {
                bool exists = false;
                objSurface = Surf.getTinSurface(strSurface, out exists);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            {
                System.Windows.Forms.MessageBox.Show(strSurface + " is not available.");
            }

            Profile objProfile = null;


            if (dblAlignOffset != 0)
            {
                Prof.removeProfile(objAlignOff.ObjectId, strName);
            }
            else
            {
                Prof.removeProfile(idAlign, strName);
            }
            ObjectId idStyle = default(ObjectId);
            ObjectId idLabel = default(ObjectId);

            using (BaseObjs._acadDoc.LockDocument())
            {
                using (Transaction TR = BaseObjs.startTransactionDb())
                {
                    ObjectId idSurf  = objSurface.ObjectId;
                    ObjectId idLayer = Layer.manageLayers(strLayerName);
                    string   mess    = string.Format("WALL,{0},{1},{2},{3},{4}", idAlign, idSurf, idLayer, idStyle, idLabel);
                    BaseObjs.write(mess);

                    try
                    {
                        objProfile       = Prof.addProfileBySurface(strName, idAlign, idSurf, idLayer, idProfileStyle, idStyleLabelSet);
                        objProfile.Layer = strLayerName;
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception exp)
                    {
                        Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(exp.Message);
                    }

                    TR.Commit();
                }
            }


            if (dblAlignOffset != 0)
            {
                ProfilePVI      objPvi      = null;
                List <PNT_DATA> varPnt_Data = new List <PNT_DATA>();
                PNT_DATA        vPnt_Data   = new PNT_DATA();

                for (int i = 0; i <= objProfile.PVIs.Count; i++)
                {
                    objPvi           = objProfile.PVIs[i];
                    vPnt_Data.STA    = objPvi.Station;
                    vPnt_Data.z      = objPvi.Elevation;
                    vPnt_Data.OFFSET = dblAlignOffset;
                    varPnt_Data.Add(vPnt_Data);
                }

                fWall1.PNTSDESIGN = varPnt_Data;
                return(objAlignOff.ObjectId);
            }
            return(idAlign);
        }
Beispiel #6
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 #7
0
        private void CreateProfil(double station1, double station2)
        {
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // gets the existing profile
                Autodesk.Civil.DatabaseServices.Profile profile = profiles.SingleOrDefault(x => x.Name == profileName);
                ProfilePVICollection pPviCollExist = profile.PVIs;

                ObjectId labelSetId     = CivilApplication.ActiveDocument.Styles.LabelSetStyles.ProfileLabelSetStyles["_No Labels"];
                ObjectId profileStyleId = CivilApplication.ActiveDocument.Styles.ProfileStyles["Design Profile"];
                ObjectId oProfileId     = Autodesk.Civil.DatabaseServices.Profile.CreateByLayout("Copied profile", newAlig.ObjectId, newAlig.LayerId, profileStyleId, labelSetId);
                Autodesk.Civil.DatabaseServices.Profile newProfile = tr.GetObject(oProfileId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Profile;

                if (pPviCollExist.Count <= 3)
                {
                    Point2d point1 = new Point2d(station1, profile.ElevationAt(station1));
                    Point2d point2 = new Point2d(station2, profile.ElevationAt(station2));

                    CreateProfileFromEntities(profile.Entities[0], profile, newProfile, point1, point2);

                    tr.Commit();
                }
                else
                {
                    // finding values near our start station for copied alignment
                    ProfilePVI pPviExistStart = pPviCollExist.GetPVIAt(station1, profile.ElevationAt(station1));
                    ProfilePVI pPviExistEnd   = pPviCollExist.GetPVIAt(station2, profile.ElevationAt(station2));

                    ProfileEntity pEntitiyAfter = profile.Entities.EntityAtId(pPviExistStart.EntityAfter);
                    Point2d       pviEndPoint   = new Point2d(pEntitiyAfter.StartStation, pEntitiyAfter.StartElevation);

                    ProfileEntity pEntitiyBefore = profile.Entities.EntityAtId(pPviExistEnd.EntityBefore);
                    Point2d       pviStartPoint  = new Point2d(pEntitiyBefore.EndStation, pEntitiyBefore.EndElevation);



                    ProfileEntity pStartEntity = pPviExistStart.VerticalCurve;
                    ProfileEntity pEndEntity   = pPviExistEnd.VerticalCurve;

                    ProfileEntityCollection pEntities = profile.Entities;
                    uint index = pEntities.FirstEntity;

                    Point2d firstPoint = new Point2d(station1, profile.ElevationAt(station1));
                    CreateProfileFromEntities(pStartEntity, profile, newProfile, firstPoint, pviEndPoint);

                    int counter = 0;

                    try
                    {
                        while (true)
                        {
                            ProfileEntity pEntity = pEntities.EntityAtId(index);

                            if (pEntity.StartStation >= station1 && pEntity.EndStation <= station2)
                            {
                                Point2d StartPoint = new Point2d(pEntity.StartStation, pEntity.StartElevation);
                                Point2d EndPoint   = new Point2d(pEntity.EndStation, pEntity.EndElevation);
                                CreateProfileFromEntities(pEntity, profile, newProfile, StartPoint, EndPoint);
                                counter++;
                            }

                            if (pEntity.StartStation <= station1 && pEntity.EndStation >= station2)
                            {
                                oneEntity = pEntity;
                            }

                            index = pEntity.EntityAfter;
                        }
                    }

                    catch
                    {
                        if (counter == 0)
                        {
                            Point2d point1 = new Point2d(station1, profile.ElevationAt(station1));
                            Point2d point2 = new Point2d(station2, profile.ElevationAt(station2));
                            CreateProfileFromEntities(oneEntity, profile, newProfile, point1, point2);
                        }

                        else
                        {
                            Point2d endPoint = new Point2d(station2, profile.ElevationAt(station2));
                            CreateProfileFromEntities(pEndEntity, profile, newProfile, pviStartPoint, endPoint);
                        }
                    }

                    tr.Commit();
                }
            }
        }