Пример #1
0
 public void ShowModalDialog()
 {
     using (MyForm form = new MyForm())
     {
         form.ShowInTaskbar = false;
         Application.ShowModalDialog(form);
         if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
         {
             Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n" + form.INPUT_LEFTBOTTOM.Text);
         }
     }
 }
Пример #2
0
        public void BlockArrayFill()
        {
            using (MyForm autoBlockFill = new MyForm())
            {
                autoBlockFill.ShowInTaskbar = false;
                Application.ShowModalDialog(autoBlockFill);
                if (autoBlockFill.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    //Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("矩形范围面积为:\n" + autoBlockFill.recArea);

                    Database db = HostApplicationServices.WorkingDatabase;
                    ObjectId refid;

                    using (Transaction trans = db.TransactionManager.StartTransaction())
                    {
                        BlockTable       bt         = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                        BlockTableRecord modelSpace = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                        refid = db.OverlayXref(@"d:\Tmp\door.dwg", "name");// 把外部文件转换为块定义
                        //BlockReference br = new BlockReference(Point3d.Origin, refid); // 通过块定义创建块参照

                        for (int i = 0; i < 3; i++)
                        {
                            double baseX = i * 900;
                            for (int j = 0; j < 3; j++)
                            {
                                Point3d        baseP = new Point3d(autoBlockFill.pointLeftB.X + baseX, autoBlockFill.pointLeftB.Y + j * 600, 0);
                                BlockReference br    = new BlockReference(baseP, refid); // 通过块定义创建块参照
                                modelSpace.AppendEntity(br);                             //把块参照添加到块表记录
                                trans.AddNewlyCreatedDBObject(br, true);                 // 通过事务添加块参照到数据库
                                br.Dispose();
                            }
                        }
                        trans.Commit();
                    }
                }
            }
        }