Run routine(s) after drawing initialize
I've created a lisp routine to create different templates based on drawing type(rough grading/precise/etc.). In the routine I'm setting all of the layers and linetypes, as well as inserting the necessary blocks. The routine works really well until the inserting blocks is introduced. It launches a new completely empty template, sets the layers and linetypes, asks for the block insertion, appears to have worked, but no blocks get inserted.
I'm confident that the routine for inserting blocks works, it just doesn't work when trying to fire it off at the same time as the drawing open. If I separate it and call the function after the drawing is loaded it will insert the blocks. I've tried using DELAY after launching the blank template, no go.
Is there a variable or method that I can use to tell it not to call the function(s) until after the drawing has finished opening/is initialized?
Code snippet to give you an idea:
(defun GetTemplate ( / )
(vla-Add (vla-get-Documents (vlax-get-acad-object)) "!Fast.dwt")
)
;------------------------------------------------------------------
(defun c:TemplateRG ( / )
(GetTemplate)
(LayersRG)
(BlocksRG)
)
Thanks in advance.
Comments
-
If I understand correctly (LayersRG) works but (BlocksRG) does not. If that is so then you should look at the differences between those two functions.
0 -
if you add an new drawing to the Application these will initialize an new instance of the lisp engine. all Functions are availlable if initialision is finished. Try to set the sysvar lispinit to 0 .
and if you change your code in this case like my example is, the code will wait, if the vla-object of the new Docoment will be available and step forward in the code.
(defun c:TemplateRG ( / GetTemplate)(defun GetTemplate ( / )
(vla-Add (vla-get-Documents (vlax-get-acad-object)) "!Fast.dwt")
)(if(GetTemplate)
(progn
(LayersRG)
(BlocksRG)
)
))0 -
@Martin Drese said:
if you add an new drawing to the Application these will initialize an new instance of the lisp engine. all Functions are availlable if initialision is finished. Try to set the sysvar lispinit to 0 .
and if you change your code in this case like my example is, the code will wait, if the vla-object of the new Docoment will be available and step forward in the code.
(defun c:TemplateRG ( / GetTemplate)
(defun GetTemplate ( / )
(vla-Add (vla-get-Documents (vlax-get-acad-object)) "!Fast.dwt")
)(if(GetTemplate)
(progn
(LayersRG)
(BlocksRG)
)
))Thanks for the reply Martin.
That did not work unfortunately. Running the function that calls GetTemplate, LayersRG, & BlocksRG still doesn't fully "load" the drawing before inserting the blocks. It's pretty much instantaneous from when the function is ran to it asking for block insertion. You can't hardly tell it's even opened a new drawing and it's asking for the block insertion point. AFTER selecting an insertion point all other startup routines and functions are called.
I need it to ask for insertion after everything else(on_start/on_doc_load) has already loaded.
0 -
@Chris Schildmeier:
If you add a (princ ...) statement to your on_doc_load.lsp you will notice that it does not load after (vla-add ...). It will load after GetTemplate finishes (if the new document is still open).
Try adding:(load "on_doc_load.lsp")
After:(vla-add ...)
And if you have an s::startup function you will have call it explicitly as well.0