batch opening drawings using vba

batch opening drawings using vba

adywren
Contributor Contributor
747 Views
3 Replies
Message 1 of 4

batch opening drawings using vba

adywren
Contributor
Contributor
We have developed a VBA macro that sequentially opens any *.dwg & *.dwt files found within a nominated root folder & changes X-ref paths to a new server location based on find/ replace strings. Whilst the code will process 100-200 or so dwgs & change 100's of x-ref paths with no problem we then get a run of errors during opening of the next 100 or so dwgs?

Error numbers noted while opening a dwg file...

438
-2147418111
-2145320823
-2145320900

Anyone have any insight or solution to our problem or an explanation of the error numbers?
0 Likes
748 Views
3 Replies
Replies (3)
Message 2 of 4

andrewpuller3811
Advisor
Advisor

I ran into a similar problem working with 600+ files. I ended up making a list of the files and then chopping that list into pieces and doing it in smaller batches.

 

 



If a post provides a fix for your issue, click on "Accept as Solution" to help other users find solutions to problems they might have that are similar to yours.

Andrew Puller
Maitland, NSW, Australia
Windows 11
Intel core i7 11800 @ 2.30 GHz with 32GB Ram
Civil 3d 2023
0 Likes
Message 3 of 4

Mario-Villada
Advocate
Advocate

I had a similar situation when batch plotting, I believe AutoCAd has a memory leak problem. What I would do is to Close AutoCAD every 100 dwgs and open it again, so it will flush the memory.

 

Another thing that would help is to disable the Undo command every time you open a dwg to avoid memory leaks by doing this:

Acad.ActiveDocument.SendCommand('Undo C N ');

 

Hope this helps.

 

Mario.

0 Likes
Message 4 of 4

Anonymous
Not applicable

If this is indeed a memory problem that cannot be surmounted without restarting AutoCAD then you might try something like the following approach:

 

- Have the VBA application make a list of all the files to be processed. Have it save the list as a structured text file.

- Have the VBA application remove the successfully processed files from the list and have it resave the structured list each time. The list will develop into all the files yet to be processed. You might as well have it save a list of all the processed files. It might come in handy when trouble shooting.

- Have the VBA check for (and then use) a populated unprocessed file list when it first runs instead of having it start from fresh.

 

You would then run the VBA how for how many times it takes to leave an empty processed file list.

0 Likes