Ejemplo n.º 1
0
        checkBldgElev(string strAlignName)
        {
            TinSurface objSurface = null;
            bool       exists     = false;

            try
            {
                ObjectId idLayer = Layer.manageLayers(fStake.GCAL_LAYER);
                BaseObjs.regen();
            }
            catch (System.Exception)
            {
                Stake_GetSurfaceCPNT.getSurfaceFromXRef("STAKE", "STAKE");
                objSurface = Surf.getTinSurface("CPNT-ON", out exists);
            }

            Alignment objAlign = Align.getAlignment(strAlignName);

            string.Format("\"Test Building No. {0} :\n", strAlignName);

            Form.ControlCollection objCntrls = default(Form.ControlCollection);
            Control objCntrl = default(Control);

            if (checkBldgElevs(objAlign.ObjectId))
            {
                objCntrls = (Form.ControlCollection)fGrid.Frame08.Controls;

                objCntrl = objCntrls[strAlignName];
                objCntrl.BackgroundImage = System.Drawing.Image.FromFile("R:\\TSET\\VBA\\CHECK.bmp");

                objCntrls = (Form.ControlCollection)fGrid.Frame10.Controls;

                objCntrl         = objCntrls[string.Format("cmd{0}", strAlignName.Substring(5))];
                objCntrl.Enabled = true;
            }
            else
            {
                objCntrls = (Form.ControlCollection)fGrid.Frame08.Controls;

                objCntrl = objCntrls[strAlignName];
                objCntrl.BackgroundImage = System.Drawing.Image.FromFile("R:\\TSET\\VBA\\X.bmp");

                objCntrls = (Form.ControlCollection)fGrid.Frame10.Controls;

                objCntrl         = objCntrls[string.Format("cmd{0}", strAlignName.Substring(5))];
                objCntrl.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        setBldgElevRef(Alignment objAlign)
        {
            TinSurface objSurface = null;
            bool       exists     = false;

            try
            {
                objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                if (!exists)
                {
                    Stake_GetSurfaceCPNT.getSurfaceFromXRef("STAKE", "STAKE");
                    objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                }
            }
            catch (System.Exception)
            {
            }
            ObjectId idBldg = objAlign.GetPolyline();
            Point3d  pnt3d  = idBldg.getCentroid();

            Point3d pnt3dCen = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            if (pnt3dCen.Z == -99999.99)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Invalid Elevation at Reference Point - Exiting.......");
                return;
            }

            //Set objCircle = addcircle(pnt3dCEN, 3)
            //objCircle.color = acRed
            //objCircle.Update

            double dblAngTar = 0;
            int    intMark   = 0;

            idBldg.getEastWestBaseLineDir(ref dblAngTar, ref intMark);

            Point3d pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            double dblSlope = System.Math.Round((pnt3dTar.Z - pnt3dCen.Z) / 100, 4);

            //Set objCircle = addcircle(pnt3dTAR, 3)
            //objCircle.color = acYellow
            //objCircle.Update

            if (dblSlope == 0)
            {
                dblAngTar = dblAngTar + PI / 2;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3d    = pnt3dCen.traverse(dblAngTar, 100);
                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acGreen
                //   objCircle.Update

                if (System.Math.Round(dblSlope, 3) == 0)
                {
                    pnt3d = pnt3dCen.traverse(dblAngTar - PI / 2, 100);
                    //back to original orientation
                    pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                    //     Set objCircle = addcircle(pnt3dTAR, 3)
                    //     objCircle.color = acCyan
                    //     objCircle.Update
                }
            }
            else if (dblSlope < 0)
            {
                dblAngTar = dblAngTar + PI;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acBlue
                //   objCircle.Update

                dblSlope = -dblSlope;
            }

            BlockReference objBlkRef = null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                try
                {
                    List <string> attVals = new List <string> {
                        dblSlope.ToString()
                    };
                    objBlkRef       = Blocks.addBlockRef("G:\\TOOLBOX\\Slparrow_STAKE.dwg", pnt3dCen, dblAngTar, attVals);
                    objBlkRef.Layer = string.Format("STAKE-BLDG-{0}-LABEL", objAlign.Name);
                }
                catch (System.Exception)
                {
                }
                tr.Commit();
            }

            idBldg.delete();

            TypedValue[] tvs = new TypedValue[6] {
                new TypedValue(1001, "BLDG"),
                new TypedValue(1040, pnt3dCen.X),
                new TypedValue(1040, pnt3dCen.Y),
                new TypedValue(1040, pnt3dCen.Z),
                new TypedValue(1040, dblAngTar),
                new TypedValue(1040, dblSlope)
            };

            objAlign.ObjectId.setXData(tvs, "STAKE");
        }
Ejemplo n.º 3
0
        makeProfile(ObjectId idAlign, List <POI> varpoi, string nameProfile, string profileMode, bool boolMod)
        {
            string   strLayerName = string.Format("PROFILE-{0}", nameProfile);
            ObjectId idLayer      = Layer.manageLayers(strLayerName);

            ObjectId idProfileStyle         = ObjectId.Null;
            ObjectId idProfileLabelSetStyle = ObjectId.Null;

            try
            {
                idProfileStyle = Prof_Style.getProfileStyle(nameProfile);
                if (idProfileStyle == ObjectId.Null)
                {
                    idProfileStyle = Prof_Style.getProfileStyle("Standard");
                }
            }
            catch (System.Exception)
            {
            }

            try
            {
                idProfileLabelSetStyle = Prof_Style.getProfileLabelSetStyle(nameProfile);
                if (idProfileLabelSetStyle == ObjectId.Null)
                {
                    idProfileLabelSetStyle = Prof_Style.getProfileLabelSetStyle("Standard");
                }
            }
            catch (System.Exception)
            {
            }

            Profile  objProfile = null;
            ObjectId idProfile  = ObjectId.Null;

            objProfile = Prof.getProfile(idAlign, nameProfile);
            if (objProfile != null)
            {
                objProfile.ObjectId.delete();
            }

            string nameAlign = Align.getAlignName(idAlign);

            switch (profileMode)
            {
            case "ByLayout":
                objProfile = Prof.addProfileByLayout(nameProfile, nameAlign, strLayerName, "Standard", "Standard");
                //objProfile = Prof.addProfileByLayout(nameProfile, idAlign, idLayer, idProfileStyle, idProfileLabelSetStyle);
                if (objProfile == null)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Failed to make {0} Profile. Exiting...", nameProfile));
                    return(idProfile);
                }
                break;

            case "BySurface":
                TinSurface objSurface = fStake.SurfaceCPNT;
                if ((objSurface == null))
                {
                    Stake_GetSurfaceCPNT.getSurfaceFromXRef("CPNT-ON", "GCAL");
                    objSurface = fStake.SurfaceCPNT;
                }

                objProfile = Prof.addProfileBySurface(nameProfile, idAlign, objSurface.ObjectId, idLayer, idProfileStyle, idProfileLabelSetStyle);
                if (objProfile == null)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Failed to make {0} Profile. Exiting...", nameProfile));
                }
                break;
            }

            TypedValue[] tvs = new TypedValue[2] {
                new TypedValue(1001, "STAKE"), new TypedValue(1000, fStake.ClassObj)
            };

            idProfile.setXData(tvs, "STAKE");

            Debug.Print("BEGIN POI IN makeProfile");

            for (int i = 0; i < varpoi.Count; i++)
            {
                Debug.Print(varpoi[i].Station + " " + varpoi[i].Elevation);
            }
            Debug.Print("END POI IN makeProfile");

            ProfilePVI objProfilePVI;

            double dblHeight = 0;

            if (nameProfile == "CURB")
            {
                dblHeight = System.Math.Round(double.Parse(fStake.cboHeight.Text) / 12, 3);
            }

            for (int i = 0; i < varpoi.Count; i++)
            {
                double dblStation = varpoi[i].Station;

                try
                {
                    objProfilePVI = objProfile.PVIs.AddPVI(dblStation, varpoi[i].Elevation + dblHeight);
                }
                catch (System.Exception)
                {
                    try
                    {
                        objProfilePVI = objProfile.PVIs.AddPVI(dblStation + 0.01, varpoi[i].Elevation + dblHeight);
                    }
                    catch
                    {
                        objProfilePVI = objProfile.PVIs.AddPVI(dblStation - 0.01, varpoi[i].Elevation + dblHeight);
                    }
                }
            }

            return(idProfile);
        }