Marc, I'd also not go for the DotNet option myself. You'd be tieing your code to ACad on Windows (only) - since the DotNet DLL would have to be loaded for you code to be run. Though nearly all the newest Batch Utilities go about it this way (or at least something similar - perhaps a separate EXE which sends messages to ACad). Samples of this type of thing (though they may have been implemented not through DotNet, but the principle is the same) is ScriptPro / AutoScript / EZScript / CadFX'x Batch Script Processor. There are even some which generate a BAT file which opens & closed acad with the new DWG and runs a script / lisp on each in turn - I class them under the same idea, though I find them inefficient in the extreme (even though they might take advantage of multi-cores you need lots of RAM to stop from crashing):
http://forums.augi.com/showthread.php?77021-How-to-create-a-routine-to-batch-process-files-or-a-directoryThe simplest method is still the scripting idea. Runs reasonably well, but you do have a temporary file and some command-calls. If you can live with that I'd stay with it - it's the least convoluted and problematic. You'll note that 90% of all lisp-only-batch programs follow this route. Samples include
Lee's Script Writer /
Kean Walmsley's /
BatchLisp.
That is if you don't want to revert acad back to the old DOS single document interface by changing the SDI sysvar to 1. It has some issues, e.g. what about starting your code if there's already more than one document open? Anyhow, if this is set, then any open of a DWG closes the previous and sets the new as current - so your code can simply continue as per BC's idea. There are some lisp-only-batch programs doing this, but they're rare and usually quite old.
The s::startup routine needs some store of which DWGs to act on. I've noted in that other thread that I was thinking of the registry. But I now think that Tim's idea of having a file listing the DWGs is better - it might even work on other OS's (if you can get the vla/x stuff functioning of course). Very few lisp stuff go about it this way, since it's quite difficult - nearly as complex as making a DotNet runner for your code. Tim's is one of the only ones I've come across.
Kean Walmsley's 2nd version is a hybrid between the script & s::startup idea. Makes it a bit less complex.
Another thing you could try is using the
VBScript's Sendkeys to swap over to the other DWG, and then start your lisp from there. But take note, SendKeys is very prone to errors as it does not wait for acad to become responsive and you could then easily send only half the lisp call (or rather acad doesn't pick up all of it) - causing an error. I'd only go with this as a very last resort.