//-------------------------------------------------
// В AutoCAD 2005...2006 работать не будет из-за
// ограничений на содержимое ResultBuffer!
//-------------------------------------------------
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using AcRx = Autodesk.AutoCAD.Runtime;
using AcEd = Autodesk.AutoCAD.EditorInput;
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
[assembly: CommandClass(typeof(Rivilis.EntGet))]
namespace Rivilis
{
public class EntGet
{
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
private static extern int acdbGetAdsName(long[] name, ObjectId objId);
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acdbEntGet")]
private static extern System.IntPtr acdbEntGet(long[] name);
[CommandMethod("DXFGet")]
static public void DXFGet()
{
AcEd.Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
AcEd.PromptEntityOptions entityOpts = new AcEd.PromptEntityOptions("\nSelect entity: ");
AcEd.PromptEntityResult rc = ed.GetEntity(entityOpts);
if (rc.Status == AcEd.PromptStatus.OK)
{
long[] ent = new long[] { 0, 0 };
acdbGetAdsName(ent, rc.ObjectId);
System.IntPtr rb = acdbEntGet(ent);
AcDb.ResultBuffer dxflist = AcRx.DisposableWrapper.Create(typeof(AcDb.ResultBuffer), rb, true) as AcDb.ResultBuffer;
if (dxflist != null)
{
foreach (TypedValue val in dxflist)
{
ed.WriteMessage("\n({0} . {1})", val.TypeCode, val.Value.ToString());
}
}
}
}
}
}