The thoughts of a CADD Manager.

Tuesday, February 22, 2005

Lisp and VBA not enough for you...try arx

ObjectArx for Dummies -

This site is a great little bigginners course for those of you (me included) that feel they are just not getting enough out of lisp and VBA.

Saturday, February 12, 2005

Farewell to a Great Associate

I have to say good by to one of the hardest working and innovative people I have met. He was a part of my core team and I hate to see him go.

I wish you well Steve! Keep in touch and I hope for the best with your new ventures as Applications Engineer with LACad.

Monday, February 07, 2005

The Implementation of Custom Commands in AutoCAD

User: "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."
CADD Manager: "That's great! What's it called?"
User: "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."
CADD Manager: "hmm, did you know that we have commands in AutoCAD that do that already?"
User: "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?

  1. Allow the user to use this lisp routine even though there is already a command in AutoCAD that does this function.
  2. 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.
  3. Remove AutoCAD from his computer and tell him to use MS Paint.
  4. Encourage him to use the AutoCAD command.
  5. 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.

Command Line

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.

Lisp – yourcommand.lsp

(defun C:yourcomm1 ()
(setvar "cmdecho" 0)
((null yourcommand)
(load "yourcommand")))
VBA – dvbfile.dvb!yourcommand

(defun C:yourcomm2 ()
(setvar "cmdecho" 0)
(vl-vbarun "dvbfile.dvb!yourcommand")
ARX – yourcommand.arx

(defun C:yourcomm3 ()
(setvar "cmdecho" 0)
(arxload "yourcommand.arx")

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.

Menu file

Here are a few examples of how to add your custom command to the menu file once it is created.


ID_yourcomm1 [yourcomm1]^C^Cyourcomm1;
ID_yourcomm2 [yourcomm2]^C^Cyourcomm2;
ID_yourcomm3 [yourcomm3]^C^Cyourcomm3;
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)
  1. Copy an existing Tool like Chamfer, or Fillet.
  2. Right click on the tool and click on properties.
  3. 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.