TheSwamp
Code Red => .NET => Topic started by: BenJones on October 30, 2008, 07:58:58 PM
-
Noob to .NET...migrating vba to .net (see faces cringing now)...
I see that you can create dxf selection filters, but I want to select an object and get the dxf codes. I have checked the object browser and done a couple of google searches and come up with nothing.
Anyone have a snippet that I can snag or some leads on how to get this info?
-
you can p/invoke entget
#region
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
//using AcExtensions; mine
using AcAp = Autodesk.AutoCAD.ApplicationServices;
#endregion
[assembly: CommandClass(typeof(ExecMethod.Commands))]
//++--
namespace ExecMethod
{
public class Commands
{
[CommandMethod("doit")]
static public void doit()
{
Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
try
{
foreach (TypedValue tv in SafeNativeMethods.EntGet(ed.GetEntity("Get It").ObjectId))
{
ed.WriteMessage("\n{0}", tv);
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
ed.WriteMessage("\n" + ex.StackTrace);
}
}
}
public static class SafeNativeMethods
{
//++-- TonyT
//++-- http://discussion.autodesk.com/forums/thread.jspa?messageID=5656222�
[DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
extern static public ErrorStatus acdbGetAdsName(out Int64 entres, ObjectId id);
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
extern static IntPtr acdbEntGet(out Int64 e);
public static ResultBuffer EntGet(ObjectId id)
{
Int64 e;
if (acdbGetAdsName(out e, id) == ErrorStatus.OK)
{
IntPtr res = acdbEntGet(out e);
if (res != IntPtr.Zero)
return ResultBuffer.Create(res, true);
}
return null;
}
}
}
-
Why do you want to get to DXF codes? What are you trying to do?
-
Thanks Daniel. I will try this out.
I am using adt schedules and they keep the their object selection in soft pointers.
So the idea is this, select a ADT schedule object and create a selection of objects that it is associated to.
Autodesk hasn't opened schedules through the api at all, so I am looking for ways around this. Any ideas?
Thanks again!
Ben
-
This worked great!
Thanks!!
-
My pleasure :-)