Aaaggghhh ... sorry ... I forgot that vla-SendCommand is asynchronous. That means the command is sent to ACad, but the rest of the Lisp runs without waiting for the command to finish.
...Back to square one ...
Another way would be to modify the Burst command to be callable from lisp without sending the command BURST. Unfortunately I can't copy that file to AUGI as there's copyright on it. I could explain how you can edit it though:
1. Open the Burst.LSP file under the Express folder under your AutoCAD program folder. E.g. mine's at C:\Program Files\AutoCAD 2008\Express. You can open it with Notepad, or preferably ACad's VLIDE command.
2. Very important ... first save as to a new file, e.g. Burst1.LSP
3. Change the line starting with (defun C:BURST (it should be the 27th line) to the following (changes marked in red);
Code:
(Defun BURST (SS1 / item bitset bump att-text lastent burst-one burst
BCNT BLAYER BCOLOR ELAST BLTYPE ETYPE PSFLAG ENAME EDATA)
4. Scroll down to near the end, there should be a portion starting with
Code:
;-----------------------------------------------------
; BURST MAIN ROUTINE
;-----------------------------------------------------
5. Comment out the (Defun BURST (/ SS1) by placing a semi-colon (; ) just before it. Also comment out its closing parenthesis, the one just before:
Code:
;-----------------------------------------------------
; BURST COMMAND
;-----------------------------------------------------
6. Comment out the (Setq SS1 (SsGet ...... line as well. It should be 5 lines below the line you first commented out in 5 above.
7. Add the following just before the (BURST-ONE ENAME) line. It should be 9 lines below the comment out in 6 above.
Code:
(setq EDATA (entget ENAME))
(if (and (= (cdr (assoc 0 EDATA)) "INSERT")
(= (cdr (assoc 67 EDATA)) PSFLAG)
)
8. Place a closing parenthesis ) just after the (BURST-ONE ENAME) line mentioned in 7 above.
9. Save the file
10. Now open the LSP you made already and change it to the following:
Code:
;;Load the modified burst lisp
(load "Burst1.LSP")
;;Ensure Model space is shown
(setvar "TILEMODE" 1)
;; Get a selection set of all objects in the Model space
(setq ss (ssget "X" '((410 . "Model"))))
;;Call the Burst function and pass the selection set
(BURST ss)
;;Step through all layouts. The lay is a variable (could be
;;called anything), which is assigned each of the values in
;;the (layoutlist) list in turn.
;;Then the following lines are executed for each value
(foreach lay (layoutlist)
;; Clear the selection set
(setq ss nil)
;; Free ram resources
(gc)
;;Change to the layout named in the lay variable by changing CTAB
(setvar "CTAB" lay)
;;Get a selection set of entities on the current tab
(setq ss (ssget "X" (list (cons 410 (getvar "CTAB")))))
;;Again call the Burst function and pass the selection set
(BURST ss)
) ;End of the foreach loop