Author Topic: LayerTable.GetUnreconciledLayers method  (Read 5357 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6144
LayerTable.GetUnreconciledLayers method
« on: September 18, 2012, 03:58:27 PM »
Has anyone used LayerTable.GetUnreconciledLayers method?
 
Of course the 'great' documentation shows to pass
 AcArray<AcDbObjectId,AcArrayMemCopyReallocator<AcDbObjectId>>* modopt(IsImplicitlyDereferenced) idArray 
with methods only used in IL.   

TheMaster

  • Guest
Re: LayerTable.GetUnreconciledLayers method
« Reply #1 on: September 18, 2012, 06:42:00 PM »
Has anyone used LayerTable.GetUnreconciledLayers method?
 
Of course the 'great' documentation shows to pass
 AcArray<AcDbObjectId,AcArrayMemCopyReallocator<AcDbObjectId>>* modopt(IsImplicitlyDereferenced) idArray 
with methods only used in IL.

AcArray<AcDbObjectId,AcArrayMemCopyReallocator<AcDbObjectId>>*
is what the managed ObjectIdCollection wraps.

But, because it was declared to take a pointer, you can't call it from verifiable managed code.

You should be able to P/Invoke the native member function directly, using something like this:

Code - C#: [Select]
  1.  
  2. public static class MyExtensions
  3. {
  4.    [DllImport("acdbxx.dll", CallingConvention=CallingConvention.ThisCall, EntryPoint=".....")]
  5.    public static extern void getUnreconciledLayers( IntPtr layerTable, IntPtr ids );
  6.  
  7.    public static void GetUnreconciledLayers( this LayerTable ltr, ObjectIdCollection ids )
  8.    {
  9.       getUnreconciledLayers( ltr.UnmanagedObject, ids.UnmanagedObject );
  10.    }
  11. }
  12.  
  13.  


Jeff H

  • Needs a day job
  • Posts: 6144
Re: LayerTable.GetUnreconciledLayers method
« Reply #2 on: September 18, 2012, 07:25:21 PM »
Thanks Tony!

BlackBox

  • King Gator
  • Posts: 3770
Re: LayerTable.GetUnreconciledLayers method
« Reply #3 on: June 05, 2013, 05:10:21 PM »
I've recently been guided to this thread, but am having some difficulty implementing.

I was smart enough to swap:
Code - C#: [Select]
  1.     public static class MyExtensions
  2.     {
  3.         [DllImport("acdbxx.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = ".....")]
  4.         public static extern void getUnreconciledLayers(IntPtr layerTable, IntPtr ids);
  5.  
  6.         public static void GetUnreconciledLayers(this LayerTable ltr, ObjectIdCollection ids)
  7.         {
  8.             getUnreconciledLayers(ltr.UnmanagedObject, ids.UnmanagedObject);
  9.         }
  10.     }
  11.  

... With (for 2013):
Code - C#: [Select]
  1.         [DllImport("acdb19.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = ".....")]
  2.  

... However, I am utterly stumped on how to determine what my EntryPoint replacement should be?  :?

I cannot seem to find any documentation on this, if it's in the ObjectARX SDK, I have that just need some guidance on where to start reading.

Cheers
« Last Edit: June 06, 2013, 02:21:50 AM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: LayerTable.GetUnreconciledLayers method
« Reply #4 on: June 05, 2013, 07:14:13 PM »
You need to get the mangled name from the acdb18.dll using Dumpbin. See a write up Sinc did a few years ago abou the usage of P/Invoke & Dumpbin: http://www.quuxsoft.com/Programming/PInvoke.aspx

This is the mangled name you need to use for 2012:
?getUnreconciledLayers@AcDbLayerTable@@QEBA?AW4ErrorStatus@Acad@@AEAV?$AcArray@VAcDbObjectId@@V?$AcArrayMemCopyReallocator@VAcDbObjectId@@@@@@@Z

Replace the "...." for the EntryPoint with the above in quotes.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: LayerTable.GetUnreconciledLayers method
« Reply #5 on: June 05, 2013, 07:35:40 PM »
Modifying Tony's sample to be more 2014'ish, I came up with this:
Code - C#: [Select]
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using Autodesk.AutoCAD.ApplicationServices;
  4. using Autodesk.AutoCAD.DatabaseServices;
  5. using Autodesk.AutoCAD.Runtime;
  6.  
  7. namespace Namespace1
  8. {
  9.     public static class MyExtensions
  10.     {
  11.         [DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?getUnreconciledLayers@AcDbLayerTable@@QEBA?AW4ErrorStatus@Acad@@AEAV?$AcArray@VAcDbObjectId@@V?$AcArrayMemCopyReallocator@VAcDbObjectId@@@@@@@Z")]
  12.         private static extern void getUnreconciledLayers(IntPtr layerTable, IntPtr ids);
  13.  
  14.         public static ObjectIdCollection GetUnreconciledLayers(this LayerTable ltr)
  15.         {
  16.             ObjectIdCollection ids = new ObjectIdCollection();
  17.             getUnreconciledLayers(ltr.UnmanagedObject, ids.UnmanagedObject);
  18.             return ids;
  19.         }
  20.  
  21.     }
  22.     public class Mycmds
  23.     {
  24.         [CommandMethod("TestMe")]
  25.         public void testme()
  26.         {
  27.             ObjectIdCollection ids = new ObjectIdCollection();
  28.             Document doc = Application.DocumentManager.MdiActiveDocument;
  29.             Database db = doc.Database;
  30.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  31.             {
  32.                 LayerTable lt = (LayerTable)db.LayerTableId.GetObject(OpenMode.ForRead);
  33.                 ids = lt.GetUnreconciledLayers();
  34.                 tr.Commit();
  35.             }
  36.             doc.Editor.WriteMessage("\nFound {0} layers", ids.Count);
  37.         }
  38.  
  39.     }
  40. }
  41.  

BlackBox

  • King Gator
  • Posts: 3770
Re: LayerTable.GetUnreconciledLayers method
« Reply #6 on: June 06, 2013, 12:41:48 AM »
You need to get the mangled name from the acdb18.dll using Dumpbin. See a write up Sinc did a few years ago abou the usage of P/Invoke & Dumpbin: http://www.quuxsoft.com/Programming/PInvoke.aspx

This is the mangled name you need to use for 2012:
?getUnreconciledLayers@AcDbLayerTable@@QEBA?AW4ErrorStatus@Acad@@AEAV?$AcArray@VAcDbObjectId@@V?$AcArrayMemCopyReallocator@VAcDbObjectId@@@@@@@Z

Replace the "...." for the EntryPoint with the above in quotes.

Dumpbin... Never heard of it before... Thank you (and Sinc) for educating me!  :-)

Cheers
"How we think determines what we do, and what we do determines what we get."

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: LayerTable.GetUnreconciledLayers method
« Reply #8 on: June 06, 2013, 09:16:22 AM »

Dumpbin... Never heard of it before... Thank you (and Sinc) for educating me!  :-)

Cheers

I use DependencyWalker instead.  Just to give you options.
Revit 2019, AMEP 2019 64bit Win 10

BlackBox

  • King Gator
  • Posts: 3770
Re: LayerTable.GetUnreconciledLayers method
« Reply #9 on: June 06, 2013, 11:31:27 AM »
TheSwamp is awesome... Thanks Kerry, and MexicanCustard!  :-)
"How we think determines what we do, and what we do determines what we get."