马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Clone the dynamic block in the same drawing file.By Virupaksha Aithal
Below code shows the procedure to clone the dynamic block with all its properties to same drawing file.
Steps:
Wblock the present dynamic block to new database using “wblock”.
Use “Insert” API to insert the database (generated in step1) with new block name
- [CommandMethod("cloneDynamic")]
- static public void cloneDynamic() // This method can have any name
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- using (Transaction tr =
- db.TransactionManager.StartTransaction())
- {
- BlockTable tb = tr.GetObject(db.BlockTableId,
- OpenMode.ForRead) as BlockTable;
- BlockTableRecord dynamic = tr.GetObject(tb["DynamicBlock"],
- OpenMode.ForRead) as BlockTableRecord;
- Database temDB = db.Wblock(dynamic.ObjectId);
- ObjectId copyId = ObjectId.Null;
- using (temDB)
- {
- copyId = db.Insert("DynamicBlockCopy", temDB, true);
- }
- tr.Commit();
- }
- }
|