块定义从一个图形传到当前图形

 public void btb()
        {
            
//先用Wblock 将指定文件内容传到临时db
            
//再用Insert传到当前图形

            Document doc 
= Application.DocumentManager.MdiActiveDocument;
            Database db 
= doc.Database;
            Database databaseFromFile 
= Getdb("c:\\blockbtr.dwg", System.IO.FileShare.Read, true);
            
using (Transaction tr = databaseFromFile.TransactionManager.StartTransaction())
            {
                BlockTable bt; BlockTableRecord btr;
                ArxHlb.CADEntAdd.GetBtBtr(databaseFromFile, tr, 
out bt, out btr, OpenMode.ForRead);

                
foreach (ObjectId bbtrId in bt)
                {
                    BlockTableRecord bbtr 
= tr.GetObject(bbtrId, OpenMode.ForRead) as BlockTableRecord;
                    
if (!(bbtr.Name.ToUpper().Contains("MODEL_SPACE"|| bbtr.Name.ToUpper().Contains("PAPER_SPACE")))
                    {
                        Database dbTemp 
= databaseFromFile.Wblock(bbtrId);

                        db.Insert(bbtr.Name, dbTemp, 
true);
                    }
                }
            }
        }

 

posted @ 2010-06-21 22:23  houlinbo  阅读(333)  评论(0编辑  收藏  举报