junqilian

如题,不更改当前比例尺,把指定点Zoom到地图中心。

 

        Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

        [CommandMethod("ZoomCenter")]
        public void ZoomCenter()
        {
            AcMapMap map = AcMapMap.GetCurrentMap();
            MgEnvelope mapExtent = map.GetMapExtent();

            double centerX = mapExtent.LowerLeftCoordinate.X + mapExtent.Width / 2;
            double centerY = mapExtent.LowerLeftCoordinate.Y + mapExtent.Height / 2;

            ed.WriteMessage("center:"+centerX.ToString()+","+centerY.ToString()+"\n");

            Point3d centerPt;
            PromptPointOptions ppo = new PromptPointOptions("Click on map to zoom center:");
            PromptPointResult ppr = ed.GetPoint(ppo);
            if (ppr.Status == PromptStatus.OK)
            {
                centerPt = ppr.Value;

                MgEnvelope newExtent = new MgEnvelope(centerPt.X - mapExtent.Width / 2,
                                                                    centerPt.Y - mapExtent.Height / 2,
                                                                    centerPt.X + mapExtent.Width / 2,
                                                                    centerPt.Y + mapExtent.Height / 2);

                map.ZoomToExtent(newExtent);
            }

        }

 

分类:

技术点:

相关文章:

  • 2021-05-20
  • 2021-04-29
  • 2021-11-01
  • 2021-08-20
  • 2021-10-28
  • 2021-07-08
  • 2021-08-29
  • 2021-11-25
猜你喜欢
  • 2021-08-03
  • 2019-07-22
  • 2021-11-27
  • 2021-10-15
  • 2021-11-21
  • 2021-09-18
  • 2021-04-26
相关资源
相似解决方案