Exemplo n.º 1
0
        GD()
        {
            object snapMode = SnapMode.getOSnap();

            try
            {
                ObjectId idPoly = ObjectId.Null;

                double dblAngDock = 0, dblAng = 0;;
                double dblLenDock = 0;

                Point3d pnt3dA = Pub.pnt3dO;                           //point AHEAD

                List <Point3d> pnts3dLim = new List <Point3d>();

                ObjectId idCgPnt0 = ObjectId.Null, idCgPnt1 = ObjectId.Null, idCgPntBeg = ObjectId.Null, idCgPntEnd = ObjectId.Null;
                string   elev = UserInput.getCogoPoint("\nSelect Dock Begin Point: ", out idCgPntBeg, ObjectId.Null, osMode: 8);
                if (idCgPntBeg == ObjectId.Null)
                {
                    return;
                }
                Debug.Print(idCgPntBeg.getHandle().ToString());

                Point3d pnt3dBeg = idCgPntBeg.getCogoPntCoordinates();
                pnts3dLim.Add(pnt3dBeg);


                elev = UserInput.getCogoPoint("\nSelect Dock End Point", out idCgPntEnd, idCgPntBeg, osMode: 8);
                if (idCgPntEnd == ObjectId.Null)
                {
                    return;
                }
                Debug.Print(idCgPntEnd.getHandle().ToString());

                Point3d pnt3dEnd = idCgPntEnd.getCogoPntCoordinates();
                pnts3dLim.Add(pnt3dEnd);

                bool         escape = false;
                PromptStatus ps;
                Point3d      pnt3dX = UserInput.getPoint("\nSpecify point on side to grade dock: ", pnt3dBeg, out escape, out ps, osMode: 0);
                if (pnt3dX == Pub.pnt3dO || escape)
                {
                    return;
                }
                int side = 0;
                if (Geom.testRight(pnt3dBeg, pnt3dEnd, pnt3dX) > 0)
                {
                    side = -1;
                }
                else
                {
                    side = 1;
                }

                double width = 60;
                escape = UserInput.getUserInput(string.Format("\nEnter dock width: <{0}>:", width), out width, width);
                if (escape)
                {
                    return;
                }

                using (BaseObjs._acadDoc.LockDocument())
                {
                    try
                    {
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            dblAngDock = pnt3dBeg.getDirection(pnt3dEnd);
                            dblLenDock = pnt3dBeg.getDistance(pnt3dEnd);

                            double dblSlope = System.Math.Round(pnt3dBeg.getSlope(pnt3dEnd), 3);

                            dblAng = dblAngDock - pi / 2 * side;

                            ObjectIdCollection idsPoly3dX = new ObjectIdCollection();
                            List <ObjectId>    idsCgPnts  = new List <ObjectId>();

                            List <Point3d> pnts3d = new List <Point3d>();
                            pnts3d.Add(pnt3dBeg);                                           //CgPntBeg

                            //Slope is not 0
                            if (dblSlope != 0)
                            {
                                pnt3dA = pnt3dBeg.traverse(dblAng, width, -0.01);
                                pnts3d.Add(pnt3dA);                                             //Pnt 2

                                dblAng = dblAng + pi / 2 * side;
                                pnt3dA = pnt3dA.traverse(dblAng, dblLenDock, dblSlope);
                                pnts3d.Add(pnt3dA);                                             //Pnt3

                                pnts3d.Add(pnt3dEnd);                                           //Pnt4 - CgPntEnd
                                pnts3d.Add(pnt3dBeg);                                           //Pnt5 - CgPntBeg

                                idsCgPnts = pnts3d.addBrklineSegmentsDock(out idsPoly3dX, apps.lnkBrks, side, idCgPntBeg, idCgPntEnd);
                            }
                            else
                            {
                                int k = 1;

                                int intDivide = (int)System.Math.Truncate(dblLenDock / 84) + 1;

                                if (intDivide % 2 != 0)
                                {
                                    intDivide = intDivide + 1;
                                }

                                pnt3dA = pnt3dBeg.traverse(dblAng, width, -0.005);                                      //Pnt2
                                pnts3d.Add(pnt3dA);
                                k++;

                                int x = 0;
                                dblAng = dblAng + pi / 2 * side;

                                double seg    = dblLenDock / intDivide;
                                int    updown = 1;

                                for (x = 0; x <= intDivide - 1; x++)
                                {
                                    updown = -updown;
                                    pnt3dA = pnt3dA.traverse(dblAng, seg, 0.005 * updown);
                                    pnts3d.Add(pnt3dA);                                                 //points on outer edge of Dock from Pnt2 through Pnt3
                                    k++;
                                }

                                pnts3d.Add(pnt3dEnd);                                   //Pnt4 = CgPntEnd
                                int indexPntEnd = k++;

                                pnt3dA = pnt3dEnd;

                                dblAng = dblAng + pi * side;                                        //+pi because skipped turning towards bldg because we have point already

                                for (x = 0; x <= intDivide - 1; x++)
                                {
                                    pnt3dA = pnt3dA.traverse(dblAng, dblLenDock / intDivide, 0.0);
                                    pnts3d.Add(pnt3dA);                                                //points on inner edge of Dock from pntBeg to pntEnd
                                }

                                // don't need to add pnt3dBeg to end of list because it is calc'd in loop previous

                                idsCgPnts = pnts3d.addBrklineSegmentsDock(out idsPoly3dX, apps.lnkBrks, side, idCgPntBeg, idCgPntEnd, indexPntEnd);

                                List <ObjectId> idCgPntsX = new List <ObjectId>();
                                idCgPntsX.Add(idsCgPnts[1]);                                     //CgPnt 2 at dock limit away from building

                                int intUBnd = idsCgPnts.Count;
                                x = -1;
                                int n = 1;
                                k = intUBnd / 2;
                                for (int j = 1; j <= k - 1; j++)
                                {
                                    x = -x;
                                    n = n + (intUBnd - 2 * j) * x;
                                    System.Diagnostics.Debug.Print(string.Format("{0},{1}", j, n));
                                    idCgPntsX.Add(idsCgPnts[n]);
                                }

                                ObjectId idPoly3d = ObjectId.Null;
                                for (int i = 1; i < idCgPntsX.Count; i++)
                                {
                                    idCgPnt0 = idCgPntsX[i - 1];
                                    idCgPnt1 = idCgPntsX[i];

                                    idPoly3d = Draw.addPoly3d(idCgPnt0.getCogoPntCoordinates(), idCgPnt1.getCogoPntCoordinates(), "CPNT-BRKLINE");

                                    idPoly3d.lnkPntsAndPoly3d(idCgPnt0, idCgPnt1, apps.lnkBrks);

                                    idsPoly3dX.Add(idPoly3d);
                                }
                            }
                            Grading_Floor.modSurface("CPNT-ON", "Finish Surface", idsPoly3dX, false);
                            //}
                            tr.Commit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} cmdGD.cs: line: 181", ex.Message));
                    }
                }
            }
            catch (System.Exception)
            {
            }
            finally{
                SnapMode.setOSnap((int)snapMode);
            }
        }
Exemplo n.º 2
0
        GD()
        {
            ObjectId     idPoly    = ObjectId.Null;
            const string nameLayer = "CPNT-BRKLINE";

            double dblAngDock = 0;
            double dblLenDock = 0;

            Point3d pnt3dA = Pub.pnt3dO;           //point AHEAD
            Point3d pnt3dB;                        //point BACK

            int intSlopeSign = 0;

            const double pi = System.Math.PI;

            bool     exists          = false;
            ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists);

            if (!exists)
            {
                Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Run AVG - exiting .....");
            }

            List <Point3d> pnts3dLim = getDockLimits();   //use 0 as dock number i.e. do one dock at a time

            bool escape = false;

            double width = 60;

            escape = UserInput.getUserInput(string.Format("Enter dock width: <{0}>:", width), out width, width);
            if (escape)
            {
                return;
            }

            double height = 4.04;

            escape = UserInput.getUserInput(string.Format("Enter dock height: <{0}>:", height), out height, height);
            if (escape)
            {
                return;
            }

            ObjectId idDictBLDG  = Dict.getSubDict(idDictGRADEDOCK, bldgNum);       //bldgNum obtained @ getDockLimits
            ObjectId idDictDOCKS = ObjectId.Null;

            TypedValue[] tvs;
            using (BaseObjs._acadDoc.LockDocument())
            {
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        ResultBuffer rb = Dict.getXRec(idDictBLDG, "HANDLE3D");
                        if (rb == null)
                        {
                            return;
                        }
                        tvs = rb.AsArray();

                        rb = Dict.getXRec(idDictBLDG, "SLOPE");
                        if (rb == null)
                        {
                            return;
                        }
                        tvs = rb.AsArray();
                        double dblSlope = (double)tvs[0].Value;

                        rb = Dict.getXRec(idDictBLDG, "CENTROID");
                        if (rb == null)
                        {
                            return;
                        }
                        tvs = rb.AsArray();
                        Point3d pnt3dCEN = new Point3d((double)tvs[0].Value, (double)tvs[1].Value, (double)tvs[2].Value);

                        rb = Dict.getXRec(idDictBLDG, "TARGET");
                        if (rb == null)
                        {
                            return;
                        }
                        tvs = rb.AsArray();

                        Point3d pnt3dTAR = new Point3d((double)tvs[0].Value, (double)tvs[1].Value, (double)tvs[2].Value);

                        double dblAngBase = pnt3dCEN.getDirection(pnt3dTAR);

                        ObjectIdCollection idsPoly3dX = new ObjectIdCollection();
                        List <Point3d>     pnts3d     = new List <Point3d>();
                        List <ObjectId>    idsCgPnts  = new List <ObjectId>();

                        try
                        {
                            Point3d pnt3dBEG = pnts3dLim[0];
                            Point3d pnt3dEND = pnts3dLim[1];

                            dblAngDock = Measure.getAzRadians(pnt3dBEG, pnt3dEND);
                            dblLenDock = pnt3dBEG.getDistance(pnt3dEND);
                            pnt3dB     = pnt3dBEG;

                            if (pnt3dTAR != Pub.pnt3dO)
                            {
                                pnt3dA = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, pnt3dTAR.Z + Geom.getCosineComponent(pnt3dCEN, pnt3dTAR, pnt3dBEG) * (dblSlope * -1) - height);
                            }
                            else
                            {
                                pnt3dA = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, pnt3dCEN.Z - height); //assuming flat floor if pnt3dTAR is -1,-1,-1
                            }
                            pnts3d.Add(pnt3dA);                                                    //CgPnt 1
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 113");
                        }

                        ObjectId idPoly3d = ObjectId.Null;

                        if (dblSlope != 0)
                        {
                            double angDock2 = System.Math.Round(dblAngDock, 2);
                            double angBase2 = System.Math.Round(dblAngBase, 2);

                            double modAngles = 0;
                            double angDiff   = System.Math.Round(angBase2 - angDock2, 2);

                            if (angDiff == 0)
                            {
                                intSlopeSign = 1;
                            }
                            else
                            {
                                if (angBase2 > angDock2)
                                {
                                    modAngles = angBase2.mod(angDock2);
                                }
                                else
                                {
                                    modAngles = angDock2.mod(angBase2);
                                }

                                if (modAngles == 0)
                                {
                                    if (angDiff > 0)
                                    {
                                        intSlopeSign = 1;
                                    }
                                    else if (angDiff < 0)
                                    {
                                        intSlopeSign = -1;
                                    }
                                }

                                if (System.Math.Abs(angDiff) == System.Math.Round(pi / 2, 2))
                                {
                                    intSlopeSign = 0;
                                }
                            }
                        }
                        if (intSlopeSign != 0)
                        { // sloped floor
                            dblAngDock = dblAngDock - pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, width, -0.01);
                            pnts3d.Add(pnt3dA);           //CgPnt 2

                            dblAngDock = dblAngDock + pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, dblLenDock, dblSlope * intSlopeSign * 1);
                            pnts3d.Add(pnt3dA);           //Pnt3

                            dblAngDock = dblAngDock + pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, width, 0.01);
                            pnts3d.Add(pnt3dA);           //CgPnt 4

                            dblAngDock = dblAngDock + pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, dblLenDock, dblSlope * intSlopeSign * -1);
                            pnts3d.Add(pnt3dA);           //Pnt5

                            idPoly3d = pnts3d.build3dPolyDockApron("CPNT-ON", nameLayer, "GD", out idsCgPnts);
                            idsPoly3dX.Add(idPoly3d);
                        }
                        else
                        {
                            dblAngDock = dblAngDock - pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, width, -0.005);

                            pnts3d.Add(pnt3dA);     //Pnt2

                            int intDivide = (int)System.Math.Truncate(dblLenDock / 84) + 1;

                            if (intDivide % 2 != 0)
                            {
                                intDivide = intDivide + 1;
                            }

                            int x = 0;
                            dblAngDock = dblAngDock + pi / 2;
                            double seg    = dblLenDock / intDivide;
                            int    updown = 1;
                            for (x = 0; x <= intDivide - 1; x++)
                            {
                                updown = -updown;
                                pnt3dA = pnt3dA.traverse(dblAngDock, seg, 0.005 * updown);
                                pnts3d.Add(pnt3dA);
                            }

                            dblAngDock = dblAngDock + pi / 2;
                            pnt3dA     = pnt3dA.traverse(dblAngDock, width, 0.005);
                            pnts3d.Add(pnt3dA);

                            dblAngDock = dblAngDock + pi / 2;

                            for (x = 0; x <= intDivide - 1; x++)
                            {
                                pnt3dA = pnt3dA.traverse(dblAngDock, dblLenDock / intDivide, 0.0);
                                pnts3d.Add(pnt3dA);
                            }

                            idPoly3d = pnts3d.build3dPolyDockApron("CPNT-ON", nameLayer, "GD", out idsCgPnts);
                            idsPoly3dX.Add(idPoly3d);

                            List <ObjectId> idCgPntsX = new List <ObjectId>();

                            idCgPntsX.Add(idsCgPnts[1]);     //CgPnt 2 at dock limit away from building

                            int intUBnd = idsCgPnts.Count;
                            x = -1;
                            int n = 1;
                            int k = intUBnd / 2;
                            for (int j = 1; j <= k - 1; j++)
                            {
                                x = -x;
                                n = n + (intUBnd - 2 * j) * x;
                                System.Diagnostics.Debug.Print(string.Format("{0},{1}", j, n));
                                idCgPntsX.Add(idsCgPnts[n]);
                            }
                            for (int i = 1; i < idCgPntsX.Count; i++)
                            {
                                List <ObjectId> idsCogoPnts = new List <ObjectId> {
                                    idCgPntsX[i - 1], idCgPntsX[i - 0]
                                };
                                idPoly3d = BrkLine.makeBreakline(apps.lnkBrks, "GD", out idPoly, idsCogoPnts);
                                idsPoly3dX.Add(idPoly3d);
                            }
                        }
                        Grading_Floor.modSurface("CPNT-ON", "Finish Surface", idsPoly3dX, false);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 238");
                }
            }
        }