Jump to content

Question about the use of acaddoc.lsp


MarcoW

Recommended Posts

I have read and understand a lot of the use of the acad.lsp and acaddoc.lsp file. I know that AutoCAD searches the support file search paths for these files. I even use my own files as startup routines.

 

But what happens if I have 10 support file search paths and in let's say 5 paths (folders) I have put an acaddoc.lsp file.

 

To me (I tried) it looks as if it doesn't work. Allthought there is much info available, I have not found the answer. How does AutoCAD handle this?

 

Another question in advance, for I have the idea that there can only be one acaddoc.lsp file...: how would I fix the startup of routines on startup of a drawing without acaddoc.lsp and the Startup Suite. The last one is "kinda buggy" I discovered.

 

Any help / advice is again much appreciated.

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • MarcoW

    9

  • alanjt

    7

  • ReMark

    3

  • lpseifert

    1

Top Posters In This Topic

Posted Images

 

But what happens if I have 10 support file search paths and in let's say 5 paths (folders) I have put an acaddoc.lsp file.

The acaddoc.lsp that is 'highest' in the support path will be loaded. This file can be found by

(findfile "acaddoc.lsp")

Another question in advance, for I have the idea that there can only be one acaddoc.lsp file...: how would I fix the startup of routines on startup of a drawing without acaddoc.lsp and the Startup Suite. The last one is "kinda buggy" I discovered.

What other options do you need? There's the use of acad.doc, but you need to set the variable ACADLSPASDOC. There's also the use of AcadXXXXdoc.lsp. but that's not recommended. Easiest to use acaddoc.lsp

Link to comment
Share on other sites

Why do you have multiple acaddoc.lsp files? Are they for different routines used for different types of projects? Just curious. Or maybe I'm jealous? I always had only one lonely acaddoc.lsp. What am I missing out on?

Link to comment
Share on other sites

No, I am creating some application for my collegues and I use an acaddoc.lsp file tho do certain things.

 

Someone told me that it was not the best way to use an acaddoc.lsp file of my own for in such case my collegues acaddoc.lsp would be overruled.

 

Thats why...

 

Now I figured this code, to check if there is an acaddoc.lsp file loaded in the open / running AutoCAD session. If yes, then I will add a line to load my own acaddoc.lsp. If no, then I will create one, and put the line in also.

 

 
; main routine
(defun CheckForAcadDoc (/)
 (if
   (findfile "acaddoc.lsp")
    (AddLinesToAcadDoc) ; if there is an acaddoc.lsp file already
    (MakeAcadDoc) ; if there is not an acaddoc.lsp file
 )
 (princ)
)
(princ)
; sub routine
; in case there is an AcadDoc.lsp
; then it will ad the line (load "c:\\MyAcadDoc.lsp")

(defun AddLinesToAcadDoc (/ AcadDocFile File Line) ;add a line to the acaddoc.lsp file to load Myacaddoc.lsp
 (setq AcadDocFile (findfile "acaddoc.lsp")
Line     "(load \"c:\\\\MyAcadDoc.lsp\")" ; set my path etc. correctly
 )
 (if
   (setq File (open AcadDocFile "a") ; a = append = add to the bottom
   )
    (write-line Line File)
    (alert "Could not find file allthough there should be one..!?")
 )
 (princ)
)
(princ)
(defun MakeAcadDoc (/ Line MyFileName) ; create an acaddoc.lsp file
 (setq Line "(load \"c:\\\\MyAcadDoc.lsp\")") ; assuming that this would be a folder in the support file search path
 (if
   (setq MyFileName (open "c:\\acaddoc.lsp" "w")) ; the file is not htere so it will be created
    (write-line Line MyFileName)
    (alert "Could not find file allthough there should be one..!?")
 )
 (princ)
)
(princ)

 

Please help me to make this code better or correct me if I am getting things all wrong.

 

What bothers me is that I do not know how to retrieve one of the current support file search paths (to store the newly created acaddoc.lsp file in).

Link to comment
Share on other sites

Seems like there should be an easier way for you to give your colleagues what they without all this hassle. What made you decide on this approach?

Link to comment
Share on other sites

What bothers me is that I do not know how to retrieve one of the current support file search paths (to store the newly created acaddoc.lsp file in).

 

Use the ACADPREFIX system variable to list the current defined Support Files Search Paths.

 

Regards,

Link to comment
Share on other sites

I leave the acaddoc.LSP to be reserved for the office (automatically loads if found) and I use the MNL/MNU loading process. I have my MNU with some custom key accelerators, toolbars, etc. named AlanThompson.MNU, then I have my startup file (changes settings, loads my LISP routines, etc.) and it's called AlanThompson.MNL

 

If you have a menu loaded (CUI/CUIX/MNU) and AutoCAD finds an MNL file with the same name, it will automatically load it with every session. This way you don't mess with the acaddoc.LSP or have to deal with that POS Startup Suite.

Link to comment
Share on other sites

Alan, thanks for the reply.

 

The contents of the *.mnl file, is that plain lisp?

So I can put in there what I else would put in my own acaddoc.lsp?

If so, then I am happy!

Link to comment
Share on other sites

Alan, thanks for the reply.

 

The contents of the *.mnl file, is that plain lisp?

So I can put in there what I else would put in my own acaddoc.lsp?

If so, then I am happy!

Treat the MNL just like a the acaddoc.LSP

Just make sure you have a loaded MNU with a corresponding name. :wink:

Link to comment
Share on other sites

Thanks for this information. I allways thought that an *.mnl file was part of a menu. Never touched it... This is great!

 

I have a menu (*.mnu) loaded upon install of my application. After this install there must be a restart of AutoCAD.

When this AutoCAD session is closed there appears the CUIX file. THis has the same name as the *.mnu file.

 

So if I renamy my own acaddoc.lsp to "thenameofcuix.mnl" it will work. Too bad I cannot try now but I will do one of these days. Maybe tonight, or otherwise next week for I am going to hobby a bit with beer 8) this weekend.

Link to comment
Share on other sites

Thanks for this information. I allways thought that an *.mnl file was part of a menu. Never touched it... This is great!

 

I have a menu (*.mnu) loaded upon install of my application. After this install there must be a restart of AutoCAD.

When this AutoCAD session is closed there appears the CUIX file. THis has the same name as the *.mnu file.

 

So if I renamy my own acaddoc.lsp to "thenameofcuix.mnl" it will work. Too bad I cannot try now but I will do one of these days. Maybe tonight, or otherwise next week for I am going to hobby a bit with beer 8) this weekend.

In short: yes.

Link to comment
Share on other sites

I just use a typical lisp file to load all my programs.

I made a lisp file with NO DEFUN just the autoload function

Make a autoload for each of your paths.

(autoload "c:/my path/program.vlx" '("pro"));_my program

(autoload "c:/my path/another_program.vlx" '("b_pro"));_my other program

Then save the lisp file and then put it in your startup suite so it will be loaded every time AutoCAD starts

When you leave off the defun the functions are loaded automatically

Now when I create a new program I just add another autoload to the file

Autoload will only load the file when the hot key or command name is typed or called from a button.

Like in the example above when I type pro on the command line autocad uses the path to load the program.vlx file but only when it is called.

I find this much easer than other options

Link to comment
Share on other sites

I just use a typical lisp file to load all my programs.

I made a lisp file with NO DEFUN just the autoload function

Make a autoload for each of your paths.

 

(autoload "c:/my path/program.vlx" '("pro"));_my program

(autoload "c:/my path/another_program.vlx" '("b_pro"));_my other program

 

Then save the lisp file and then put it in your startup suite so it will be loaded every time AutoCAD starts

 

When you leave off the defun the functions are loaded automatically

Now when I create a new program I just add another autoload to the file

Autoload will only load the file when the hot key or command name is typed or called from a button.

 

Like in the example above when I type pro on the command line autocad uses the path to load the program.vlx file but only when it is called.

I find this much easer than other options

That's basically the same thing I do, except I just piggy back on my custom MNU file. I've also found the Startup Suite to sketchy about loading functions at times.

Link to comment
Share on other sites

JohnM:

thanks for the explain but I am aware of the method withoud defun. I use it in some parts of my program.

 

JohnM & AlanJT:

The Startup Suite has always done a good job for me and I never encountered any failure using it. And I had a lot in there, believe me. But from the moment I tried to add stuff in there programatically it all went wrong. It has never come to a success allthough I have tried big time.

 

So in the end I decided not to use the Startup Suite any more. And since today, my own acaddoc.lsp is renamed to "marcow.lsp" and it is fired up by a *.mnl file.

 

Thanks again ALanJT for the tip.

 

For me: this issue is solved.

Link to comment
Share on other sites

JohnM:

thanks for the explain but I am aware of the method withoud defun. I use it in some parts of my program.

 

JohnM & AlanJT:

The Startup Suite has always done a good job for me and I never encountered any failure using it. And I had a lot in there, believe me. But from the moment I tried to add stuff in there programatically it all went wrong. It has never come to a success allthough I have tried big time.

 

So in the end I decided not to use the Startup Suite any more. And since today, my own acaddoc.lsp is renamed to "marcow.lsp" and it is fired up by a *.mnl file.

 

Thanks again ALanJT for the tip.

 

For me: this issue is solved.

I meant the your marcow.lsp should be renamed marcow.MNL.

 

eg.

mnl.PNG

Link to comment
Share on other sites

AlanJT you are right but I cannot encrypt the *.mnl to vlx. So I use the *.mnl only to poit to the *.vlx.

Why do you keep your files in VLX form?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...