在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 public ObjectId InsertBlock(string fileName)
2 { 3 ObjectId blockId; 4 //图形数据库读取外部图块 5 Database blockDatabase = new Database(false, true); 6 blockDatabase.ReadDwgFile(fileName, System.IO.FileShare.Read, false, string.Empty); 7 blockDatabase.CloseInput(true); 8 9 Database db = HostApplicationServices.WorkingDatabase; 10 using(Transaction trans = db.TransactionManager.StartTransaction()) 11 { 12 BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite); 13 string blockName = SymbolUtilityServices.GetBlockNameFromInsertPathName(fileName); 14 //将外部图块插入到当前模型空间 15 blockId = db.Insert(blockName, blockDatabase, false); 16 trans.Commit(); 17 } 18 return blockId; 19 } |
请发表评论