How to rename the dynamic block name.

How to rename the dynamic block name.

TSYUK
Contributor Contributor
192 Views
0 Replies
Message 1 of 1

How to rename the dynamic block name.

TSYUK
Contributor
Contributor

Hello!

 

I would like to know how to change the dynamic block name.

 

The below code is good for static block but for the dynamic block, it does not work as i expected.

 

Please, give me a clue or solution to get dynamic block name changed.

 

 

  1.   [CommandMethod("RENBLK")]
  2.         public void Test()
  3.         {
  4.             Document doc = AcAp.DocumentManager.MdiActiveDocument;
  5.             Database db = doc.Database;
  6.             Editor ed = doc.Editor;
  7.  
  8.             using (Transaction tr = db.TransactionManager.StartTransaction())
  9.             {
  10.                 BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
  11.                 if (bt.Has("BAT-10"))
  12.                 {
  13.                     BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt["BAT-10"], OpenMode.ForWrite);
  14.                     btr.Name = "VUU-10";
  15.                 }
  16.                 tr.Commit();
  17.             }
  18.         }
0 Likes
193 Views
0 Replies
Replies (0)