public static void TestMinimumSurroundingBox()
        {
            var currentDoc = Application.DocumentManager.MdiActiveDocument;
            var editor     = currentDoc.Editor;
            var database   = currentDoc.Database;
            // Only select polyline and polyline 2d.
            ObjectId polylineId = ObjectId.Null;

            while (true)
            {
                var options = new PromptEntityOptions("\n选择一条曲线:");
                var result  = editor.GetEntity(options);
                if (result.Status == PromptStatus.OK)
                {
                    polylineId = result.ObjectId;
                    break;
                }

                if (result.Status == PromptStatus.Cancel)
                {
                    break;
                }

                editor.WriteMessage("\n选择无效");
            }

            if (polylineId.IsNull)
            {
                return;
            }

            using (var transaction = database.TransactionManager.StartTransaction())
            {
                IEnumerable <Point3d> points = CurveUtils.GetDistinctVertices(polylineId, transaction);
                var boundingBox = CurveUtils.CalcMinimumSurroundingBox(points);
                var polyline    = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                for (int i = 0; i < boundingBox.Length; i++)
                {
                    polyline.AddVertexAt(i, new Point2d(boundingBox[i].X, boundingBox[i].Y), 0, 1, 1);
                }
                polyline.ColorIndex = 2;

                var modelspaceId = SymbolUtilityServices.GetBlockModelSpaceId(database);
                var modelspace   = transaction.GetObject(modelspaceId, OpenMode.ForWrite) as BlockTableRecord;
                modelspace.AppendEntity(polyline);
                transaction.AddNewlyCreatedDBObject(polyline, true);
                transaction.Commit();
            }
        }