// 开始具体的调试操作
        private ExternalCmdResult CreateViewport(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;

            //// var vp1 = AddinManagerDebuger.PickObject<Entity>(docMdf.acEditor);
            //var hd = Utils.ConvertToHandle("AA07");
            //var vp2 = hd.GetObjectId(docMdf.acDataBase).GetObject(OpenMode.ForRead) as Viewport;
            //vp2.UpgradeOpen();
            //var lot = LayoutManager.Current.GetLayoutId("NewLayout4011").GetObject(OpenMode.ForRead) as Layout;
            //vp2.RotateViewport(_docMdf, lot, new Point2d(0, 0), 30.0 / 180 * Math.PI);

            //return ExternalCmdResult.Commit;
            // 从模型空间中获取视口裁剪框
            var     pl_Model      = AddinManagerDebuger.PickObject <Curve>(docMdf.acEditor);
            Point3d bottomLeftPt  = default(Point3d);
            Point3d bottomRightPt = default(Point3d);
            double  bottomLength  = 0;
            var     succ          = GraphicalElementsSelector.GetPoint(docMdf.acEditor, "选择图纸的左下角点", out bottomLeftPt);

            if (!succ)
            {
                return(ExternalCmdResult.Cancel);
            }
            succ = GraphicalElementsSelector.GetPoint(docMdf.acEditor, "选择图纸的右下角点", out bottomRightPt);
            if (!succ)
            {
                return(ExternalCmdResult.Cancel);
            }
            succ = GraphicalElementsSelector.GetDouble(docMdf.acEditor, "图纸宽度(布局空间的单位)", out bottomLength,
                                                       defaultValue: 420, allowNegative: false);
            if (!succ)
            {
                return(ExternalCmdResult.Cancel);
            }

            var modelUcs = docMdf.acEditor.GetCurrentView().Ucs;

            // 打开布局
            var               lm = LayoutManager.Current;
            Layout            layout;
            ObjectId          layoutId;
            Form_LayoutLister f = new Form_LayoutLister(docMdf);

            f.ShowDialog();
            if (f.CreateNewLayout)
            {
                var layoutName = "NewLayout" + DateTime.Now.Minute + DateTime.Now.Second;
                layoutId = lm.GetLayoutId(layoutName);
                if (!layoutId.IsValid)
                {
                    // 重启事务
                    docMdf.RestartTransaction(commitCancel: false);
                    //
                    layoutId = LayoutUtil.CreateLayout(layoutName);
                    layout   = layoutId.GetObject(OpenMode.ForRead) as Layout;
                    //
                    LayoutUtil.SetPlotSettings(layout, "A3", "monochrome.ctb", "交通院道路室 121");
                }
                else
                {
                    layout = LayoutManager.Current.GetLayoutId(name: layoutName).GetObject(OpenMode.ForRead) as Layout;
                }
            }
            else if (f.Layout != null)
            {
                layout = f.Layout;
            }
            else
            {
                return(ExternalCmdResult.Cancel);
            }

            // 创建视口
            lm.SetCurrentLayoutId(layout.Id);
            CreateViewport(docMdf, modelUcs, layout, pl_Model, bottomLeftPt, bottomRightPt, bottomLength);
            // LayoutUtil.SwitchLayout();
            return(ExternalCmdResult.Commit);
        }