Wednesday, September 4, 2013

AutoCAD performance issues and VBA

Here is a reason why you may not want to use VBA if you have 64-bit version of AutoCAD 2008 - AutoCAD 2013.

Background

Initializing VBA System...

By just initializing the VBA system running for example VBAIDE, some commands in AutoCAD will take 10 times longer. It might be more or less depending on different factors. No DVB needs to even be loaded for this to happen.

Using ProcMon I found that without VBA initialized and loaded a QSAVE command resulted in less than 2100 registry and file events.

But with VBA initialized QSAVE caused almost 950,000 registry and file events. No wonder QSAVE took so long. Many file and registry events are done multiple times and seems to be related to the number of folders AutoCAD usually search files in.

Changing system variables like INDEXCTL, SAVEFIDELITY and PROXYGRAPHICS did not help even though they in other cases can speed up the time it takes to save drawings.

Why is this happening?

With VBA component initialized, AutoCAD has to check for any callbacks registered in VBA component even for standard AutoCAD commands. This verification is consumes time as the communication is across processes.

Autodesk ships the 32-bit VBA version in an out-of-process server with 64-bit AutoCAD (up until AutoCAD 2013 where VBA 6.3 is used). Therefore, a lot of marshaling is required going between the out-of-process VBA server and 64-bit AutoCAD. As a result, 64-bit VBA is slower than 32-bit VBA.

This problem should not exist in AutoCAD 2014 because VBA 7.1 is used and is available in a native 64-bit version, but for some reason it did for me. Eventually I figured out that reinstalling AutoCAD 2014 and VBA completely solved the issue.

Solution

Downgrading to AutoCAD 32-bit on Windows 32-bit is probably not desirable as a solution. A better solution or workaround is to upgrade to AutoCAD 2014 (but that could cause problems with 32bit VB6 controls that are not available for 64-bit) or better yet porting the VBA application to .NET DLL (using VB.NET or C#). JTB World can help with porting of VBA to .NET.

See also this post: AutoCAD 2014 supports VBA 64-bit

No comments:

Post a Comment

Subscribe to the comments feed

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Subscribe to this blog
JTB World's website | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.