找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1258|回复: 0

[分享] Changing block definition of an Block reference

[复制链接]

已领礼包: 593个

财富等级: 财运亨通

发表于 2013-5-25 02:45:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. [CommandMethod("chageBlock")]
  2. public static void chageBlock()
  3. {
  4.     Document doc = Application.DocumentManager.MdiActiveDocument;
  5.     Database db = doc.Database;
  6.     Editor ed = doc.Editor;
  7.     PromptEntityOptions options =
  8.         new PromptEntityOptions("\nSelect block reference");
  9.     options.SetRejectMessage("\nSelect only block reference");
  10.     options.AddAllowedClass(typeof(BlockReference), false);
  11.     PromptEntityResult acSSPrompt = ed.GetEntity(options);
  12.     if (acSSPrompt.Status != PromptStatus.OK)
  13.         return;
  14.     using (Transaction Tx = db.TransactionManager.StartTransaction())
  15.     {
  16.         //get the reference
  17.         BlockReference blockRef = Tx.GetObject(acSSPrompt.ObjectId,
  18.                                OpenMode.ForRead) as BlockReference;
  19.         //block table record...
  20.         BlockTable blockTable = Tx.GetObject(db.BlockTableId,
  21.                                     OpenMode.ForRead) as BlockTable;
  22.         //set the test as new block if present
  23.         if (blockTable.Has("TEST"))
  24.         {
  25.             blockRef.UpgradeOpen();
  26.             //set the id of the test block
  27.             blockRef.BlockTableRecord = blockTable["TEST"];
  28.         }
  29.         Tx.Commit();
  30.     }
  31. }
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,

评分

参与人数 1D豆 +2 收起 理由
ScmTools + 2 很给力!资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-25 09:50 , Processed in 0.275565 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表