I have lots multileaders with block and attributes in my drawing.
What I want to do is to go through all objects in the drawing and then update the attribute of multileaders.
I know C# a little, here is my code, does anybody know how to do this?
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace Update_Mleader
{
public class Update_Mleader
{
[CommandMethod("UpdateMleaderAttr")]
public void UpdateMleader()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
foreach (ObjectId entId in btr)
{
Entity ent = tr.GetObject(entId, OpenMode.ForRead) as Entity;
if (ent != null)
{
if (ent.GetType() == typeof(MLeader))
{
// how to update the attribute of the mleader?
// example, if the attribute Tag is "XCODE"
// and i want to update the TextString to "100"
}
}
}
tr.Commit();
}
ed.Regen();
}
}
}