OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: stephan_35 on December 02, 2009, 08:35:48 AM

Title: Another way to use DocActivated Event ?
Post by: stephan_35 on December 02, 2009, 08:35:48 AM
Hello,

Here is my trouble, i have to reload automatically my tools when user open a new file, or when user swith between allready loaded autocad files.

I have a try with DocActivatedEvent, but i didn't put a function but an lisp order like
"(load "D:/test.lsp")"

So , it look like work fine , but an error appear :
Quote
Commande: Une erreur : fonction incorrecte: 2

An error : Incorrect function : 2  ???

Well, i know that is not the best way to use it, but i'll be very please to do it this way  ;)

Code (autolisp) Select

(load "D:/test.lsp")


then open another drawing, or swith between allready loaded drawing.
Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 02, 2009, 12:53:03 PM
Is there some reason why you don't just use code in acaddoc.lsp to load your form handler code when needed?
Title: Re: Another way to use DocActivated Event ?
Post by: stephan_35 on December 02, 2009, 01:07:00 PM
Quote from: owenwengerd on December 02, 2009, 12:53:03 PM
Is there some reason why you don't just use code in acaddoc.lsp to load your form handler code when needed?

Hello Owen,

Yes, in fact this tool is load on demand, with a load order in an autocad menu.

I would like to keep acad***.lsp safe.

In fact trouble look like only a chek if order is a function ?

So, is it possible to work this way ? , if it is possible  ;)

Best regards
Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 02, 2009, 01:44:54 PM
If you already load a menu, just put your lisp code in the correspnding .mnl file so that it loads with every drawing.  Alternatively, use the Startup Suite or the VLXLoad utility on my web site to demand load your lisp code.  Both of these approaches achieve the objective without modifying the acaddoc.lsp file.
Title: Re: Another way to use DocActivated Event ?
Post by: stephan_35 on December 02, 2009, 02:16:30 PM
Quote from: owenwengerd on December 02, 2009, 01:44:54 PM
If you already load a menu, just put your lisp code in the correspnding .mnl file so that it loads with every drawing.  Alternatively, use the Startup Suite or the VLXLoad utility on my web site to demand load your lisp code.  Both of these approaches achieve the objective without modifying the acaddoc.lsp file.

Owen,

I'm using fas file, and using VLXLoad seems too complicated for my level of knowledge .

Sould'nt be possible to accept lisp order without error in DocActivated Event ?

Best regards.
Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 02, 2009, 02:46:50 PM
Quote from: stephan_35 on December 02, 2009, 02:16:30 PM
Sould'nt be possible to accept lisp order without error in DocActivated Event ?

It might be possible in some cases, but given the potential complications, I would not spend time pursuing this approach.
Title: Re: Another way to use DocActivated Event ?
Post by: stephan_35 on December 02, 2009, 03:42:44 PM
Quote from: owenwengerd on December 02, 2009, 02:46:50 PM
It might be possible in some cases, but given the potential complications, I would not spend time pursuing this approach.

Understanding what you mean , anyway, thanks again.

Best regards.
Title: Re: Another way to use DocActivated Event ?
Post by: Danner on December 03, 2009, 02:32:41 AM
Quote from: owenwengerd on December 02, 2009, 01:44:54 PM
.... or the VLXLoad utility on my web site to demand load your lisp code. 
Ooh nice! Owen is there any chance of extending this utility so it includes brx/des versions?

Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 03, 2009, 07:37:40 AM
Yes, I will add Bricscad support at some point.
Title: Re: Another way to use DocActivated Event ?
Post by: Fred Tomke on December 03, 2009, 08:26:51 AM
Hello, guys, I believe that we won't be the last who have to manage it I will publish our thoughts about it and the resulting solution.

We start AutoCAD from an external Manager. After starting it, our VLX file will be loaded automatically by (vl-load-all "myApp.vlx").
If you have no external manager which has access to AutoCAD you have other opportunities:

You just have to make sure that the vlx is loaded in all drawings. We make it using (vl-load-all).
If the vlx is loaded in all drawings OnDocActivated will work properly.
But there is one case which does still not work: OnEndDrawingOpen. That means thare must be an event when a new drawing will be created or opened. This can be done at the time when loading the lisp. Since (vl-load-all ..) also loads the lisp in newly opened drawings, we just added some lines at the end of the whole VLX-project.

Code (autolisp) Select

(DCL_PALETTE_DOITORCLOSE layer_sc_ltm 'c:layer_sc_ltm_OnDocActivated nil)


As you can see, all our functions have to be loaded before. We make this sure by addings these line at the end.

But what does DCL_PALETTE_DOITORCLOSE do?
It calls OnDocActivaed manually if this form is loaded and active.

Code (autolisp) Select
(defun DCL_PALETTE_DOITORCLOSE (oControl symFunc lstArg / uErg)
  (if (and oControl (dcl_Form_IsActive oControl))
    (if (dcl_Form_IsVisible oControl)
      (if symFunc (setq uErg (vl-catch-all-apply symFunc lstArg)))
      (dcl_Form_close oControl)
    ); if
  ); if
  uErg
); DCL_PALETTE_DOITORCLOSE


Hope it was understandable
Fred
Title: Re: Another way to use DocActivated Event ?
Post by: Danner on December 03, 2009, 09:06:50 AM
Personally my interest was to combine a vlxload utility inconjunction with my app's installer. (Tricky for me!)

This could invisibly load a small routine into any AutoDesk/Bricssys applications on a computer, so after a first-time install - a new user can type the routine name, in the same way as say "doslib" or "opendcl" and my application is launched (and creates file support paths, loads menus etc, if they are not there).

For me - it just neatly gets round that issue of the initial install before my mnl file is loaded.
Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 03, 2009, 10:01:35 AM
That's how it should be used, except that I recommend against changing or adding support paths. Your code can use the functions from VLXLoad to determine where your files are, so there is no need to mess with the user's support paths -- it should simply specify the complete path for support files.
Title: Re: Another way to use DocActivated Event ?
Post by: Danner on December 03, 2009, 10:41:58 AM
Quote from: owenwengerd on December 03, 2009, 10:01:35 AM
....there is no need to mess with the user's support paths -- it should simply specify the complete path for support files.
Interesting, I would much prefer that.  However please correct me if I'm wrong - but I think I'm stuck with written support paths in Tools>options>files as my application uses its own shape and pat files.
Title: Re: Another way to use DocActivated Event ?
Post by: owenwengerd on December 03, 2009, 12:01:35 PM
You may be right about shp and pat files.