Esempio n. 1
0
        private void btn_adjust_road_start_Click(object sender, EventArgs e)
        {
            Editor ed = cadSer.Application.DocumentManager.MdiActiveDocument.Editor;


            Database db     = HostApplicationServices.WorkingDatabase;
            var      middoc = cadSer.Application.DocumentManager.MdiActiveDocument;


            ObjectId plineID  = ed.GetEntity(new PromptEntityOptions("\n选取多段线!!!")).ObjectId;
            var      doc_lock = middoc.LockDocument();

            DBObject dbo;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                dbo = trans.GetObject(plineID, OpenMode.ForWrite);

                while (!dbo.GetType().Equals(typeof(Polyline)))
                {
                    ed.WriteMessage("\n刚才选取的不是Pline,请重新选择!!!");
                    plineID = ed.GetEntity(new PromptEntityOptions("\n选取多段线!!!")).ObjectId;
                    dbo     = trans.GetObject(plineID, OpenMode.ForWrite);
                }



                Point3d poindstart = ed.GetPoint(new PromptPointOptions("\n选取起点")).Value;

                Polyline polyline = (Polyline)dbo;

                Vector3d tmp_vector = polyline.StartPoint.GetAsVector() - poindstart.GetAsVector();
                tmp_vector = new Vector3d(tmp_vector.X, tmp_vector.Y, 0);

                if (tmp_vector.Length > 1.0)
                {
                    polyline.ReverseCurve();
                    zjyCAD.ToModelSpace(polyline, db);
                }



                trans.Commit();
            }
            doc_lock.Dispose();
        }