[code]
using System ;
using System.Collections ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices ;
using Autodesk.AutoCAD.DatabaseServices ;
using Autodesk.AutoCAD.EditorInput ;
[assembly: CommandClass(typeof(ClassLibrary.Class))]
namespace ClassLibrary
{
public class Class
{
static public void PrintXdata()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult res = ed.GetEntity("\nSelect entity: ");
if (res.Status != PromptStatus.OK) return;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity ent = tr.GetObject(res.ObjectId,OpenMode.ForRead) as Entity;
if (ent != null)
{
ResultBuffer xData = ent.GetXDataForApplication(null);
if (xData != null)
{
foreach (TypedValue val in (IEnumerable) xData)
{
ed.WriteMessage("\nCode = {0} Value = {1}", val.TypeCode, val.Value);
}
}
}
tr.Commit();
}
}
}
}
[/code]