
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello! I'm pretty familiar with VBA, but I have an interesting and specific problem for which I don't have a good solution. I have 2 commands added to my startup acad2018.lsp file: one for loading a DLL containing many method definitions and calls to VBA macros I've created (loaded using netload) and the other for loading a DVB containing many macros I've created (loaded using vl-vbaload). Both of these files are loaded when AutoCAD starts up, so I used the vl-vbaload command to prevent a message from popping up every time it tries to load a DVB that is already loaded.
I have a VBA macro that publishes several paperspace layouts within my drawing to PDF by means of configuring a DSD file and then sending the PUBLISH command to print from that DSD. When plotting (with background plot disabled, which is apparently necessary for this kind of plot), AutoCAD reloads and plots each sheet until it has plotted them all.
The problem is that, after my sheets print to PDF, AutoCAD loads another instance of my DVB file. It seems that AutoCAD runs through its startup routine after publishing. And somehow, AutoCAD doesn't recognize that the DVB loaded at startup was already loaded and it loads two instances of the same DVB, which is causing issues when trying to use the macros stored in the DVB. I thought that the vl-vbaload command would have prevented this, but it doesn't appear to.
As of right now, I've been able to take advantage of my DLL (which calls my print macro) to retroactively handle this. My DLL contains a command method that invokes the print macro, and I am able to unload one instance of the DVB after telling AutoCAD to run the macro, but I don't care for this method. Because I use the SendCommand() (asynchronous) method to publish from within my macro, AutoCAD publishes after all of my code stops running. So I've been able to unload the original DVB first and then let it publish and load the DVB again. Surely this is not the way to do it.
Does anyone know why or how my DVB is getting loaded again and how to prevent it? Any better ideas than mine on how to work around this issue? Any help is greatly appreciated!
Solved! Go to Solution.