Jump to content

2 Step Command Alias in PGP File


EVGA Buzzer

Recommended Posts

Hi

 

I have a bunch of Lisp routines that I have used for years. I am new to AutoCAD 2010 and am trying to get these command abbreviations to work. I have tried just loading the old Lisp file. It loads, but the commands abbreviations are not working. So, I decided to just put them in the pgp file. I can do things in there like redefine "C" to be COPY instead of CIRCLE. What has me stumped is how to do a 2 part command like Zoom -> Window.

 

With the Lisp file working, I could type ZW for Zoom -> Window. The command looked like this -

 

(DEFUN C:ZW () (COMMAND "ZOOM" "W"))

 

All of the Command Aliases in the 2010 pgp file are single keystroke commands. I want to know if I can define multiple keystroke commands like Zoom -> Window in the pgp file. How do I represent the interim return character?

 

Also, any ideas why after I load this old Lisp file, CAD says its loaded but none of the command abbreviations work ?

 

I did search around here but could not find a solution.

 

Thanks in advance !!

 

EVGA Buzzer

Link to comment
Share on other sites

I've never used 2010, but if it's the same as previous versions you can only call commands, not their options from the acad.pgp file.

 

Try putting your lisp commands [e.g. (DEFUN C:ZW () (COMMAND "ZOOM" "W")) ] in a text file and save it as acaddoc.lsp somewhere in your support path, restart autocad and see if that works.

 

If you were to post the .lsp file that doesn't work anymore, it would be easier to debug it.

Link to comment
Share on other sites

Well no wonder I could not get it to work in the pgp file. I was hopeful that I would come across the solution but I guess I need to go back to figuring out why the Lisp file loads but the commands in it do not work. The Lisp file it attached.

 

I put it in a support directory. To Load it, I select Tools, Load Application [or Tools, AutoLISP, Load Application]. This gets me to the Load/Unload Applications menu. I select and load from there. I tried putting stuff in the Startup Suite but I did not get too far with that. I had a VLX file in there. To be honest, its been a while and I don't quite remember all the details of that. Need to read the help files again.

 

The LISP file is attached for reference. Does it HAVE to be named acaddoc.lsp? I have another file named that but it does not have the command abbreviations in it that I want. I have tried loading that file too. I could paste the commands I want in there. Is there something specific about that file name ? I am uploading that file too.

 

THANKS !

acad.lsp

acaddoc.lsp

Link to comment
Share on other sites

When AutoCAD starts up, it looks for a file named "Acad.lsp" and loads it if found.

When a drawing is loaded (including at startup), AutoCAD looks for a file named "Acaddoc.lsp" and loads it if found.

 

So yes, create/append "Acad.lsp" and put in there, anything that is needed once "per session", and create/append "acaddoc.lsp" and put in there, anything that is needed on a per drawing basis.

 

* Do not mess with the existing files named "acad20xx.lsp" and "acad20xxdoc.lsp".

* Do not mess with the startup suite.

* Put "acad.lsp" and "Acaddoc.lsp" in the TOP path in your support file search path, (add one if desired).

* If you have arx files that need to be auto-loaded, you can use a file named "Acad.rx" - post back for more details if needed.

* Acad.pgp is good for single action shortcuts, but things like you posted (Command "._Zoom" "_W") go in "Acaddoc.lsp"

* Lastly, when a lisp file loads (including "acad.lsp" and "acaddoc.lsp"), if there is an error, the loading STOPS, so if there is an error on line 2, lines 3-200 DO NOT load. Add a line at the BOTTOM of these files like this (princ "\n ACAD.LSP LOADED") and (princ "\n ACADDOC.LSP LOADED") and then if you don't see these messages at the command prompt, you will know you have an error...

Link to comment
Share on other sites

Thanks again !! I will try what you have described. What I still do not understand it why when I load my Lisp file manually [with Tools, Load Application], AutoCAD says it loaded. There is no error message but the commands still do not work. Someone I work with suggested that the Lisp file may be getting loaded but then over written ? Or perhaps there is something else that is conflicting with my Lisp commands ?

 

I will do exactly what you said and see what happens but I just don't understand why CAD says it loaded my Lisp file with no errors but then acts like it did not load it at all.

 

EVGA Buzzer

Link to comment
Share on other sites

The files you posted were edited copies of an Acad2000. lsp file and were trying to load files that probably do not exist on your 2010 install. After making backups of the old files, try putting the attached acaddoc.lsp file in your support path, as suggested by Mr. McSwain. The file contains nothing but your command lisps [e.g. (DEFUN C:ZW () (COMMAND "ZOOM" "W")) ]

acaddoc.lsp

Link to comment
Share on other sites

maybe rkmcswain suggested this, or maybe he said not to do it, but i just have such two-step commands at the end of my (acad2008.lsp) file. works fine, every time, on every version of AutoCAD i've used.

Link to comment
Share on other sites

From Help (2008)

Warning Do not modify the reserved acad2008.lsp file. Autodesk provides the acad2008.lsp file, which contains AutoLISP defined functions that are required by AutoCAD. This file is loaded into memory immediately before the acad.lsp file is loaded.

If you do a repair, reinstall or upgrade the acadXXXX.lsp file will be overwritten. Best just to create an acaddoc.lsp file.
Link to comment
Share on other sites

maybe rkmcswain suggested this, or maybe he said not to do it, but i just have such two-step commands at the end of my (acad2008.lsp) file. works fine, every time, on every version of AutoCAD i've used.

 

It will work (Well, if "AcadLspAsDoc = 1, which is not advised either**), but as pointed out by lpseifert, there is just no reason to use this file, because Autodesk provides a file for users ("acaddoc.lsp"), that it will never touch.

 

That is not even the main reason. You edited "acad2008.lsp" (Are you sure you didn't mean "Acad2008doc.lsp"?). What happens when you move to 2009 or 2010 or whatever? Then you have to migrate your changes to the "Acad2009.lsp" or "Acad2010.lsp", etc.

 

On the other hand, "Acad.lsp" and "Acaddoc.lsp" work in any version of AutoCAD, they only need to be in the support file search path. In fact, if you follow this tip, then migrating to a new version (or even another install of same version) consists of adding a single path to your support file search path - and that is it.

 

** AcadLspAsDoc was provided in R2000 to help ease the migration from R14, but it really has no purpose now, since there is no reason to load "Acad.lsp" for each drawing.

Link to comment
Share on other sites

i do mean acad2008.lsp.... but yes, new versions require me to copy and paste content. not too hard with only a few commands to migrate. (acadlspasdoc = 0 for me)

 

please explain the acaddoc.lsp more.... if i put my custom stuff in this will it work just the same but not need altering when i upgrade?

 

ps i have only acad2008doc.lsp, not acaddoc.lsp in my program files/support folder - is this the same file? can i create one with just my stuff in to avoid any problems? thanks for the knowledge sharing, appreciate it

Link to comment
Share on other sites

i do mean acad2008.lsp.... but yes, new versions require me to copy and paste content. not too hard with only a few commands to migrate. (acadlspasdoc = 0 for me)

 

True, but if you have hundreds of users.... well, you get the point.

 

please explain the acaddoc.lsp more.... if i put my custom stuff in this will it work just the same but not need altering when i upgrade?

Correct.

 

ps i have only acad2008doc.lsp, not acaddoc.lsp in my program files/support folder - is this the same file? can i create one with just my stuff in to avoid any problems? thanks for the knowledge sharing, appreciate it

Right again. "Acaddoc.lsp" (and "Acad.lsp") are *user* files. They do not come with AutoCAD, hence the usage of "create/append" earlier.

 

I would suggest creating your own folder and adding files like "acad.lsp", "Acaddoc.lsp", "acad.pgp", etc. (as needed...) and then adding this folder to the TOP of your support file search path (as described here in more detail)

Link to comment
Share on other sites

  • 4 weeks later...
The files you posted were edited copies of an Acad2000. lsp file and were trying to load files that probably do not exist on your 2010 install. After making backups of the old files, try putting the attached acaddoc.lsp file in your support path, as suggested by Mr. McSwain. The file contains nothing but your command lisps [e.g. (DEFUN C:ZW () (COMMAND "ZOOM" "W")) ]

 

 

Thanks to all. It worked perfectly :)

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...