Any development on Audit via .NET? Regards, Dale
Autodesk does not implement Audit method for both Database (managed .NET) and AcDbDatabase (unmanaged ObjectARX) classes. The easiest way is to use SendStringToExecute() method. If you still want to use only .NET, you can import native methods from acdbxx.dll (xx = 17 for A2007/2008/2009, 18 for A2010/2011/2012, and 19 for A2013).
AutoCAD unmanaged code has many different audit methods for many object types (Database, Header, Table, XData,...), so you can try to loop through each objects and call its own audit method of each object type. The following code will give us a hint to get started.
[CommandMethod("AuditNet")] public static void AuditNet() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; // This method does NOT work auditDatabase(db.UnmanagedObject); // This method works doc.SendStringToExecute("_AUDIT Y ", false, false, true); } #region Unmanaged methods for Audit
[DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbDatabase@@QEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditDatabase(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbHeader@@QEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditHeader(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbTable@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditTable(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbTableStyle@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditTableStyle(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?auditXData@AcDbDatabase@@QEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditXData(IntPtr color); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcCmColor@@QEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditColor(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcCmComplexColor@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditComplexColor(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbAssocPersSubentId@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditAssocPersSubent(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbAssocSimplePersSubentId@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditAssocSimplePersSubent(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbBlkRefObjectContextData@@UEAAXPEAVAcDbAuditInfo@@PEAVAcDbBlockReference@@AEAHAEA_N@Z")] public static extern double auditBlkRefObjectContextData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbDataTable@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditDataTable(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbDimensionObjectContextData@@UEAAXPEAVAcDbAuditInfo@@PEAVAcDbDimension@@@Z")] public static extern double auditDimensionObjectContextData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbEntity@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditEntity(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbImpDimObj@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditImpDimObj(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbMTextAttributeObjectContextData@@UEAAXPEAVAcDbAuditInfo@@PEAVAcDbText@@AEAHAEA_N@Z")] public static extern double auditMTextAttributeObjectContextData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbMTextObjectContextData@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@PEAVAcDbMText@@@Z")] public static extern double auditMTextObjectContextData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbObject@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditObject(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbSortentsTable@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditSortentsTable(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbTextObjectContextData@@UEAAXPEAVAcDbAuditInfo@@PEAVAcDbText@@AEAHAEA_N@Z")] public static extern double auditTextObjectContextData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbUcsPlane@@QEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@PEAVAcDbObject@@@Z")] public static extern double auditUcsPlane(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDbXObject@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditXObject(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDmDimstyleData@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditDimstyleData(IntPtr pointer); [DllImport("acdb17.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode, EntryPoint = "?audit@AcDmPropertyBaseSet@@UEAA?AW4ErrorStatus@Acad@@PEAVAcDbAuditInfo@@@Z")] public static extern double auditDmPropertyBaseSet(IntPtr pointer);
#endregion
-Khoa
Thank you very much. If I manage to make some headway I'll repost. Regards, Dale
Hi Dale,
I even did not try to use individual audit methods. So it would be great if later you could share something on your progress.
-Khoa