马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [CommandMethod("chageBlock")]
- public static void chageBlock()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- PromptEntityOptions options =
- new PromptEntityOptions("\nSelect block reference");
- options.SetRejectMessage("\nSelect only block reference");
- options.AddAllowedClass(typeof(BlockReference), false);
- PromptEntityResult acSSPrompt = ed.GetEntity(options);
- if (acSSPrompt.Status != PromptStatus.OK)
- return;
- using (Transaction Tx = db.TransactionManager.StartTransaction())
- {
- //get the reference
- BlockReference blockRef = Tx.GetObject(acSSPrompt.ObjectId,
- OpenMode.ForRead) as BlockReference;
- //block table record...
- BlockTable blockTable = Tx.GetObject(db.BlockTableId,
- OpenMode.ForRead) as BlockTable;
- //set the test as new block if present
- if (blockTable.Has("TEST"))
- {
- blockRef.UpgradeOpen();
- //set the id of the test block
- blockRef.BlockTableRecord = blockTable["TEST"];
- }
- Tx.Commit();
- }
- }
Changing block definition of an Block reference By Virupaksha Aithal
Below code shows the procedure to modify the block definition for block reference. Code, prompts the user to select a block reference and changes its definition so that block reference becomes reference for new block definition,
|