示例#1
0
文件: cmdSPG.cs 项目: 15831944/EM
        SPG(string nameCmd)
        {
            gp.pnt3d1 = Pub.pnt3dO;
            gp.pnt3d2 = Pub.pnt3dO;
            PromptStatus ps    = PromptStatus.Cancel;
            string       desc1 = "";
            string       desc2 = "";
            bool         escape;
            object       mode = SnapMode.getOSnap();

            try
            {
                Point3d  pnt3d1   = Pub.pnt3dO;
                ObjectId idCgPnt1 = CgPnt.selectCogoPointByNode("\nSelect FIRST point-node: ", ref pnt3d1, out escape, out ps, osMode: 8);
                if (ps == PromptStatus.Cancel)
                {
                    return;
                }
                desc1     = idCgPnt1.getCogoPntDesc();
                gp.pnt3d1 = pnt3d1;

                Point3d  pnt3d2   = Pub.pnt3dO;
                ObjectId idCgPnt2 = CgPnt.selectCogoPointByNode("\nSelect SECOND point-node: ", ref pnt3d2, out escape, out ps, osMode: 8);
                if (ps == PromptStatus.Cancel)
                {
                    return;
                }
                desc2     = idCgPnt2.getCogoPntDesc();
                gp.pnt3d2 = pnt3d2;

                SnapMode.setOSnap(1);

                do
                {
                    gp.pnt3dX = Pub.pnt3dO;
                    gp.pnt3dT = Pub.pnt3dO;

                    gp.pnt3dT = gPnt.getPoint("\nSelect Target location or press Enter to exit: ", nameCmd);
                    if (gp.pnt3dT == Pub.pnt3dO)
                    {
                        return;
                    }

                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    uint pntNum;
                    CgPnt.setPoint(gp.pnt3dX, out pntNum, desc1);
                }while (1 < 2);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdSPG.cs: line: 63");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
        }
示例#2
0
        TP4()
        {
            gp.pnt3d1 = Pub.pnt3dO;
            gp.pnt3d2 = Pub.pnt3dO;
            ps        = PromptStatus.Cancel;
            object mode = 0;

            BaseObjs.acadActivate();
            Vector3d v3d = Vector3d.XAxis;

            try
            {
                elev = UserInput.getCogoPoint("\nPick Cogo Point 1: ", out idCgPnt1, ObjectId.Null, osMode: 8);
                if (elev == "")
                {
                    return;
                }
                else
                {
                    gp.pnt3d1 = idCgPnt1.getCogoPntCoordinates();
                }

                elev = UserInput.getCogoPoint("\nPick Cogo Point 2: ", out idCgPnt2, ObjectId.Null, osMode: 8);
                if (elev == "")
                {
                    return;
                }
                else
                {
                    gp.pnt3d2 = idCgPnt2.getCogoPntCoordinates();
                }

                mode = SnapMode.getOSnap();
                SnapMode.setOSnap(8);

                gp.pnt3dX = Pub.pnt3dO;
                gp.pnt3dT = Pub.pnt3dO;

                System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;
                bool shift   = (mods & System.Windows.Forms.Keys.Shift) > 0;
                bool control = (mods & System.Windows.Forms.Keys.Control) > 0;
                gp.shift = shift;

                gp.pnt3dT = gPnt.getPoint("\nSelect Target location (CogoPoint for xSlope and distance / pick side to enter xSlope and distance: ", "cmdTP");

                if (gp.pnt3dT == Pub.pnt3dO)
                {
                    return;
                }
                else if (gp.pnt3dT.Z == 0)
                {
                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    escaped = UserInput.getUserInputDoubleAsString("\nEnter Cross Slope (+ or -): ", out xSlope, xSlope);
                    if (escaped)
                    {
                        return;
                    }

                    escaped = UserInput.getUserInputDoubleAsString("\nEnter Width: ", out width, width);
                    if (escaped)
                    {
                        return;
                    }
                    double dist  = gp.pnt3d1.getDistance(gp.pnt3d2);
                    double distX = gp.pnt3d1.getDistance(gp.pnt3dX);

                    Point2d pnt2dX = gp.pnt3dX.Convert2d(BaseObjs.xyPlane);
                    Point2d pnt2dT = gp.pnt3dT.Convert2d(BaseObjs.xyPlane);
                    double  distT  = pnt2dX.GetDistanceTo(pnt2dT);

                    gp.pnt3dT = new Point3d(gp.pnt3dT.X, gp.pnt3dT.Y, gp.pnt3dX.Z + distT * double.Parse(xSlope));

                    v3d  = gp.pnt3dT - gp.pnt3dX;
                    v3d *= double.Parse(width) / distT;
                }
                else
                {
                    gp.pnt3dX = gc.calcBasePnt3d(gp.pnt3dT, gp.pnt3d1, gp.pnt3d2);
                    if (gp.pnt3dX == Pub.pnt3dO)
                    {
                        return;
                    }

                    CgPnt.setPoint(gp.pnt3dX, out pntNum, "CPNT-ON");

                    v3d = gp.pnt3dT - gp.pnt3dX;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdTP.cs: line: 336");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }

            ObjectId idPoly   = ObjectId.Null;
            Point3d  pnt3d3   = idCgPnt2.getCogoPntCoordinates() + v3d;
            ObjectId idCgPnt3 = pnt3d3.setPoint(out pntNum);
            Point3d  pnt3d4   = idCgPnt1.getCogoPntCoordinates() + v3d;
            ObjectId idCgPnt4 = pnt3d4.setPoint(out pntNum);

            List <ObjectId> idCgPnts = new List <ObjectId> {
                idCgPnt1, idCgPnt2
            };

            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt2, idCgPnt3
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt3, idCgPnt4
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);

            idCgPnts = new List <ObjectId> {
                idCgPnt4, idCgPnt1
            };
            BrkLine.makeBreakline(apps.lnkBrks, "cmdTP4", out idPoly, idCgPnts);
        }