Has anyone successfully used either of these two reactors to initiate some code right after a drawing has been opened? I have a lisp that allows the user to select a template to start a new drawing and this works fine. Once the template drawing is opened, I'd like to have a lisp that displays a dialog where the user can populate various drawing properties which are then stored in custom drawing fields.
(defun open_template () (load "open_reactor.lsp") ;; Loads the reactor lisp (c:myreact) ;; Starts the reactor (vla-activate (vla-add (vla-get-documents (vlax-get-acad-object) template_name)) ;; template_name is obtained in a different subroutine)
I've tried every relevant drawing opening reactor callback for vlr-dwg-reactor and when I couldn't get any of them to work correctly, I then read about vlr-docmanager-reactor and so I tried all the relevant callbacks for that reactor too. Still it never quite works.
The load_dwg_props.lsp does get executed for a few of the callbacks but it always executes before the template is completely opened and after entering all the data into the dialog box and clicking the "Update Drawing Data" button, a check of the drawing properties box shows no custom fields . Yet if I run the load_dwg_props.lsp immediately after the drawing finishes opening, all the custom fields are created.
So my question is this: Is there any way lisp-wise to accomplish what I'm trying to do? I've read enough to know I could use ObjectARX or VB.NET to do this but since I still don't know LISP that well, I am hesitant to begin learning something that has a much steeper learning curve.
I reread my post and now realize I wasn't clear enough. In addition to having the load_dwg_props.lsp in my acaddoc.lsp so that it can be executed whenever it is called through c:load_dwg_props, I would also like to have this code executed automatically after the user selects a template to start a new drawing in a separate lisp. In our templates we are using fields tied to custom drawing properties as the data for our titleblocks. After opening a template, all fields show as "----" since the custom drawing property has not been loaded yet. I was just thinking it would be nice if immediately after starting a new drawing from our template lisp the Load Drawing Properties routine start.
Yes to both questions. The only lisp I don't have loading automatically in my acaddoc.lsp is the open_reactor.lsp. This is because I only want this to load immediately right before the selected template is opened in a new window. Then immediately after the template has been opened, the reactor is cleared so that opening other drawings does not fire the reactor.
So if the load_dwg_props LISP is set to execute from the ACADDOC.lsp, which is being loaded when the user selects a template to start a new drawing - surely this is accomplishing your goal and the reactor is not needed, no?
There are only two scenarios where I want the load_dwg_props.lsp to run:
1) Each time the user runs the new_project.lsp to begin a new drawing
2) The user types "load_dwg_props" in the command line.
If I add (c:load_dwg_props) to my acaddoc.lsp then the program runs every time a new drawing is started or every time an existing drawing is opened. I was thinking the only way to get the load_dwg_props.lsp program to automatically run when a template is opened from the new_project.lsp was to use a reactor.
I hope I'm being clearer. When I post messages on any message board, I'm always worried that I will either sound stupid or lame
So I guess I could have the new_project.lsp set a value for a variable that when tests true in the acaddoc.lsp, the load_dwg_props.lsp gets executed. Then I could have the load_dwg_props.lsp reset the value of the variable so that it tests false the next time any drawing is opened or started. Then only the new_project.lsp will set the condition so that the load_dwg_props.lsp initializes.
I will play around with this concept and report back my findings. As always Lee, thanks for your help!!