Esempio n. 1
0
        private void btnBuildSlope_Click(object sender, EventArgs e)
        {
            Boolean boolOK      = false;
            string  surfTAR     = string.Empty;
            string  surfDES     = string.Empty;
            int     intInterval = Convert.ToInt32(tbxInterval.Text.ToString());

            try
            {
                surfTAR = lbxSurfaceTAR.SelectedItem.ToString();
            }
            catch (Exception)
            {
                SG_Utility.Write("Select Target Surface (surface to daylight)");
                return;
            }

            double slope = Convert.ToDouble(tbxSlope.Text);

            try
            {
                surfDES = lbxSurfaceDES.SelectedItem.ToString();
            }
            catch (Exception)
            {
                SG_Utility.Write("Select Design Surface (where the results are to be placed)");
                return;
            }

            boolOK = SG_cmdSG.SG(slope, surfTAR, surfDES);
        }
Esempio n. 2
0
        public static Boolean SG(double slope, string surfTAR, string surfDES)
        {
            Boolean boolDoFirst = true;
            Boolean success     = false;

            List <Point3d> pnts3d   = new List <Point3d>();
            List <Point3d> pnts3dB1 = new List <Point3d>();
            List <Point3d> pnts3dB2 = new List <Point3d>();
            List <Point3d> pnts3dD  = new List <Point3d>();
            List <Point3d> pnts3dR  = new List <Point3d>();

            Point3d pnt3dA, pnt3dB, pnt3dC;

            BaseObjs.acadActivate();

            ObjectId idPoly3d = Select.getBrkLine("\nSelect 3D Polyline Reference: ");

            try
            {
                if (idPoly3d != ObjectId.Null)
                {
                    pnts3d = idPoly3d.getCoordinates3dList();
                    int intSide = SG_Utility.getSide(pnts3d);

                    if (pnts3d.Count > 2)
                    {
                        for (int i = 0; i < pnts3d.Count - 2; i++)
                        {
                            pnt3dA = pnts3d[i + 0];
                            pnt3dB = pnts3d[i + 1];
                            pnt3dC = pnts3d[i + 2];

                            success = setupSlope(intSide, pnt3dA, pnt3dB, pnt3dC, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                        }

                        pnt3dB = pnts3d[pnts3d.Count - 2];
                        pnt3dC = pnts3d[pnts3d.Count - 1];

                        success = setupSlope(intSide, pnt3dB, pnt3dC, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                    }
                    else
                    {
                        pnt3dA  = pnts3d[0];
                        pnt3dB  = pnts3d[1];
                        success = setupSlope(intSide, pnt3dA, pnt3dB, slope, ref boolDoFirst, surfTAR, surfDES, ref pnts3dB1, ref pnts3dB2, ref pnts3dD, ref pnts3dR);
                    }
                }
            }
            catch (SystemException)
            {
                success = false;
            }
            ObjectId           idPoly3dX  = ObjectId.Null;
            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();

            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    //idPoly3dX = pnts3dR.addPoly3d("CPNT-BRKLINE");
                    //idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dB1.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dB2.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);

                    idPoly3dX = pnts3dD.addPoly3d("CPNT-BRKLINE");
                    idsPoly3dX.Add(idPoly3dX);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            } bool exists = false;

            if (idPoly3dX != ObjectId.Null)
            {
                DialogResult result;
                result = MessageBox.Show("Add Slope Breaklines to Design Surface? \nYes to add to surface: " + surfDES
                                         + "\nNo to keep Breaklines, but not add to surface."
                                         + "\nCancel to dispose of Breaklines.",
                                         "Slope Breaklines",

                                         System.Windows.Forms.MessageBoxButtons.YesNoCancel);
                switch (result)
                {
                case DialogResult.Yes:
                    TinSurface surf = (TinSurface)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);
        }