马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[C#] 纯文本查看 复制代码
[CommandMethod("Anonymous")]
public void ExposeAnonymousBlocks()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId id in bt)
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(id, OpenMode.ForWrite);
try
{
if (btr.IsAnonymous && !btr.IsLayout)
{
ed.WriteMessage("\n{0}", btr.Name);
btr.Name = btr.Name.Substring(1);
}
}
catch
{ ed.WriteMessage("\nCouldn't rename {0}", btr.Name); }
}
tr.Commit();
}
} |