Another way to use DocActivated Event ?

Started by stephan_35, December 02, 2009, 08:35:48 AM

Previous topic - Next topic

stephan_35

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.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

Is there some reason why you don't just use code in acaddoc.lsp to load your form handler code when needed?

stephan_35

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
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

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.

stephan_35

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.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

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.

stephan_35

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.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

Danner

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?


owenwengerd

Yes, I will add Bricscad support at some point.

Fred Tomke

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:

  • call (vl-load-all "myApp.vlx") from the MNL-file of your menu (if you have one).
  • call (vl-load-all "myApp.vlx") from the acaddoc.lsp in your application product folder (if it is a supportpath).[/
  • add your vlx-file to the startup folder of APPLOAD command
  • many others...

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Danner

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.

owenwengerd

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.

Danner

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.

owenwengerd

You may be right about shp and pat files.