#region 重命名块参照
/// <summary>
/// 重命名块参照
/// </summary>
/// <param name="db"> 当前数据库</param>
/// <param name="oldBlockname">块参照旧名</param>
/// <param name="newBlockname">块参照新名</param>
public static void RenameBlock(this Database db, string oldBlockname, string newBlockname)
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//获取当前块表
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead, true);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt["dHead"], OpenMode.ForWrite, true);
btr.Name = newBlockname;
trans.Commit();
}
}
#endregion
转载于:https://www.cnblogs.com/swtool/p/3840180.html