.NET

Reply
Mentor
khoa.ho
Posts: 209
Registered: ‎09-15-2011
Message 11 of 13 (206 Views)

Re: obtaining audit results in .net

11-04-2012 09:52 PM in reply to: Dale.Bartlett

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

 

Distinguished Contributor
Dale.Bartlett
Posts: 142
Registered: ‎01-06-2003
Message 12 of 13 (187 Views)

Re: obtaining audit results in .net

11-07-2012 12:56 AM in reply to: khoa.ho

Thank you very much. If I manage to make some headway I'll repost. Regards, Dale

Mentor
khoa.ho
Posts: 209
Registered: ‎09-15-2011
Message 13 of 13 (180 Views)

Re: obtaining audit results in .net

11-07-2012 07:57 AM in reply to: Dale.Bartlett

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

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.