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

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 4704
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.   

TT

  • Swamp Rat
  • Posts: 826
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: 4704
Re: LayerTable.GetUnreconciledLayers method
« Reply #2 on: September 18, 2012, 07:25:21 pm »
Thanks Tony!

BlackBox

  • Gator
  • Posts: 3018
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 »
"Potential has a shelf life." - Margaret Atwood

Jeff_M

  • King Gator
  • Posts: 3535
  • 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: 3535
  • 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

  • Gator
  • Posts: 3018
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
"Potential has a shelf life." - Margaret Atwood

Kerry

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

--> Donate<--

MexicanCustard

  • Bull Frog
  • Posts: 460
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.
AMEP 2014/2015 64bit Win 7

BlackBox

  • Gator
  • Posts: 3018
Re: LayerTable.GetUnreconciledLayers method
« Reply #9 on: June 06, 2013, 11:31:27 am »
TheSwamp is awesome... Thanks Kerry, and MexicanCustard!  :-)
"Potential has a shelf life." - Margaret Atwood