示例#1
0
文件: FWDC.cs 项目: 15831944/BDC
 // “复制”按钮
 private void COPY_Click(object sender, EventArgs e)
 {
     using (DocumentLock documentLock = AcadApplication.DocumentManager.MdiActiveDocument.LockDocument())//锁住文档以便进行写操作
     {
         if (!zhunbei())
         {
             return;
         }
         string[] sx = FZ();
         #region 创建选择集
         Database     db      = HostApplicationServices.WorkingDatabase;
         Editor       ed      = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
         TypedValue[] filList = new TypedValue[1];
         filList[0] = new TypedValue((int)DxfCode.Start, "LWPOLYLINE");
         //filList[1] = new TypedValue(8, "JZD");
         SelectionFilter       filter = new SelectionFilter(filList);
         PromptSelectionResult res;
         res = ed.GetSelection(filter);
         SelectionSet SS = res.Value;
         if (SS == null)
         {
             return;
         }
         ObjectId[] objectId = SS.GetObjectIds();
         ObjectId   plid     = objectId[0];
         #endregion
         double       bg = 3 * ((double)SZCS.Value - 1);
         ACDBPolyline PLOBJ2;
         using (Transaction trans = db.TransactionManager.StartTransaction())
         {
             BlockTable       bt    = (BlockTable)trans.GetObject(db.BlockTableId, ACDBOpenMode.ForRead);
             BlockTableRecord btr   = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], ACDBOpenMode.ForWrite);
             ACDBPolyline     PLOBJ = (ACDBPolyline)trans.GetObject(plid, ACDBOpenMode.ForWrite);
             PLOBJ2 = (ACDBPolyline)PLOBJ.Clone();
             btr.AppendEntity(PLOBJ2);
             trans.AddNewlyCreatedDBObject(PLOBJ2, true);
             trans.Commit();
             trans.Dispose();
         }
         FLPP(sx, PLOBJ2.ObjectId, false, bg);
         init();
     }
 }