"Hey, I found this cool command off the internet that helps me out a ton. I think that it would benefit everyone in our group."
"That's great! What's it called?"
"It is a lisp routine and all I have to do is type is 'IL' in the command line. It allows me to select objects and it will isolate everything that is on the same layer as that object."
"hmm, did you know that we have commands in AutoCAD that do that already?"
"No, but I really like this one. Do you think that you could put this into our standard custom commands?"
Multiple Choice Question
- As a CADD Manager how would you deal with this situation?
- Allow the user to use this lisp routine even though there is already a command in AutoCAD that does this function.
- Tell him to stay off the internet, that he is such an idiot for not know that this already existed in AutoCAD, and leave the smart stuff to you. Then create a reactor that closes AutoCAD every time he uses that lisp routine he found.
- Remove AutoCAD from his computer and tell him to use MS Paint.
- Encourage him to use the AutoCAD command.
- Scream really load until he leaves your area, then get back looking at the odds for this week’s badminton championship.
Implementing Custom Commands is no easy task no matter how large your user group is. There are many factors to deal with - e.g. the command input methodology, training, maintenance, so and so forth.
The most important aspect of determining the implementation of a custom command is whether or not the custom command is necessary. AutoCAD already has 388 documented commands, 6 command modifiers, and 427 system variables to work with. That doesn't include the 110 express tool commands. That is a ton of stuff for anyone to remember. That is also a ton of stuff to have under your tool belt before any custom commands enter the picture. So, make sure that this statement is clear to anyone in your user group - "The CADD department will not create any custom command that duplicates an already existing AutoCAD command."
Now, lets face it, even with all of those commands, there is always a need for customization. Any user of AutoCAD knows that the program is trying to reach a ton of different markets and so they really leave most of thier commands vague enough for any market to use. Enter the custom command. Custom Commands come in all different forms. You have menu macros, diesel commands, visual LISP, VBA macros, ARX commands, just to name a few. This post is not a teaching guide on how to write in these different languages. This post describes the best way I have found to implement a custom command once it has been created in these different languages.
Once you have determined that a custom command is better suited than any of the standard AutoCAD commands, you need to determine the best way to present it to the user. I am talking about the 4 different ways of using any command - command line, toolbar button, menu pull-down, or tool palette. If you have a group of 2 which includes yourself, you may not need to present the command in more than one of these ways. But if your user group is expansive, you may save yourself and others a ton of a time by making a command available in atleast 3 of the 4 ways to present a command. Next section is how you present it in all of these forms.
I know that there is multiple ways to create a custom command to use in the command line, but I am just going to cover how to do it using lisp. I use this to implement existing Lisp routines, VBA macros, and ARX commands.
Here is an example of how to create a custom command for use in the command line.
(defun C:yourcomm1 ()
VBA – dvbfile.dvb!yourcommand
(setvar "cmdecho" 0)
(defun C:yourcomm2 ()
ARX – yourcommand.arx
(setvar "cmdecho" 0)
(defun C:yourcomm3 ()
(setvar "cmdecho" 0)
There is two items worth noting above. First is a really big pet-peeve of mine that I see all of the time. Name your lisp routines more with a name more than 4 characters in length. Don't try to bypass the pgp file and name your routine with one or two letters. Just don't do it. The other is that all custom files are soft-coded. This means that all .lsp, .dvb, and .arx files that you call like this must be located in AutoCAD’s file support search path. You can alternatively add the exact file location to the file name in any of these commands. Once you do that it is just a matter of creating a menu file and a tool palette file using those commands.
Here are a few examples of how to add your custom command to the menu file once it is created.
Toolbar Items -
ID_yourcomm1 [_Button("Yourcomm1", "yourcomm1.bmp", "ICON_16_BLANK")]^C^Cyourcomm1;
ID_yourcomm2 [_Button("Yourcomm2", "yourcomm2.bmp", "ICON_16_BLANK")]^C^Cyourcomm2;
ID_yourcomm3 [_Button("Yourcomm3", "yourcomm3.bmp", "ICON_16_BLANK")]^C^Cyourcomm3;
And as of the 2004 (with the tool palette extension) you can also put custom commands into the tool palette.
Tool Palettes (in 2005)
- Copy an existing Tool like Chamfer, or Fillet.
- Right click on the tool and click on properties.
- Change all the necessary information as indicated below.
So that is how you create the custom command using lisp. I would love to talk about training and maintenance, but this is already getting long so you will just have to wait until I got more time.
Until next time, cheers.