.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

obtaining audit results in .net

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
1057 Views, 12 Replies

obtaining audit results in .net

When using the function "ReadDwgFile" to populate
a new database from a drawing on file, if there are
any problems with the drawing being read the "ReadDwgFile"
will terminate without any error.
I found this out the hard way by stepping though some code
over and over trying to figure out why I was only finding
2 enities in a database when I knew there were far more.
I discovered the problem when I simply opened the drawing in
Acad and found that it required "recovery".
So my question is: when utilizing "ReadDwgFile" how can one
tell if there were any audit problems during the read so you
can pop up a warning to the user to recover the drawing first?
Thanks, Perry
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

One other thing. I found that when iterating through
a directory of drawings and opening each for read
I had to call dispose() on each iteration or nasty
things would happen. In every other example I have seen
so far, dispose was NOT called, the routines would
rely solely on disposing the transaction.
Is there something wrong with my routine, or should
I be disposing the databases if opening one after another?
Message 3 of 13
Anonymous
in reply to: Anonymous

>> Is there something wrong with my routine, or should
>> I be disposing the databases if opening one after another?

Yes, you must call Dispose() on a Database when you're
done with it.

Remember that it is a wrapper for an AcDbDatabase*, which
you would always delete the pointer to (in unmanaged ARX)
when you're done with it (right?). So how else would the
Database wrapper know if/when it should do that if you don't
tell it (by calling Dispose) ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"perry" wrote in message news:5149678@discussion.autodesk.com...
One other thing. I found that when iterating through
a directory of drawings and opening each for read
I had to call dispose() on each iteration or nasty
things would happen. In every other example I have seen
so far, dispose was NOT called, the routines would
rely solely on disposing the transaction.
Message 4 of 13
Anonymous
in reply to: Anonymous

Tony Tanzillo wrote:
> Yes, you must call Dispose() on a Database when you're
> done with it.
>
> Remember that it is a wrapper for an AcDbDatabase*, which
> you would always delete the pointer to (in unmanaged ARX)
> when you're done with it (right?). So how else would the
> Database wrapper know if/when it should do that if you don't
> tell it (by calling Dispose) ?
>
True Tony, I remember from doing C++/Arx that you MUST call
delete() or face headaches. But being a C# newbie I was lead
to believe that we now rely on "garbage collection" for this.
Also, virtually all of the samples in th SDK, none of them
call dispose on the database. They do call dispose on the
transaction (this disposes the database too?) Bad examples??
In my function I had to call dispose on both the transaction
and the database. Perhaph because the database was created
outside the try block?
Im thinking maybe I should start using the "using" statement
for this and forget try/catch/finally/dispose altogether.

Thanks for the input, Perry
Message 5 of 13
Anonymous
in reply to: Anonymous

Using "using" is generally preferred over try/catch/finally--if your only
reason for finally is to call Dispose().

Dan

"perry" wrote in message
news:5150338@discussion.autodesk.com...
Tony Tanzillo wrote:
> Yes, you must call Dispose() on a Database when you're
> done with it.
>
> Remember that it is a wrapper for an AcDbDatabase*, which
> you would always delete the pointer to (in unmanaged ARX)
> when you're done with it (right?). So how else would the
> Database wrapper know if/when it should do that if you don't
> tell it (by calling Dispose) ?
>
True Tony, I remember from doing C++/Arx that you MUST call
delete() or face headaches. But being a C# newbie I was lead
to believe that we now rely on "garbage collection" for this.
Also, virtually all of the samples in th SDK, none of them
call dispose on the database. They do call dispose on the
transaction (this disposes the database too?) Bad examples??
In my function I had to call dispose on both the transaction
and the database. Perhaph because the database was created
outside the try block?
Im thinking maybe I should start using the "using" statement
for this and forget try/catch/finally/dispose altogether.

Thanks for the input, Perry
Message 6 of 13
Anonymous
in reply to: Anonymous

Any comments on the Audit issue?
Message 7 of 13
Eric.Howard
in reply to: Anonymous

Did you ever find the answer to your Audit question.
Message 8 of 13
eaielli
in reply to: Anonymous

was this ever resolved?

running into the same problem.
Message 9 of 13
Dale.Bartlett
in reply to: Anonymous

Any development on Audit via .NET? Regards, Dale




______________
Yes, I'm Satoshi.
Message 10 of 13
Dale.Bartlett
in reply to: Anonymous

Any takers on Audit? Dale




______________
Yes, I'm Satoshi.
Message 11 of 13
khoa.ho
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

 

Message 12 of 13
Dale.Bartlett
in reply to: khoa.ho

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




______________
Yes, I'm Satoshi.
Message 13 of 13
khoa.ho
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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost