Nate Holt's Blog

December 3, 2010

Command substitution example, ‘Show Sigs’ – AutoCAD Electrical

Filed under: Electrical — nateholt @ 11:37 am

Substituting  your own version of a command for one called from the stock AutoCAD Electrical ribbon UI

Here’s an example of invoking your own version of a utility from the stock AutoCAD Electrical ribbon UI without modification. The key is to give your utility the same executable command name that the ribbon calls. Then add your utility to the normal AutoCAD “Startup Suite”.

The sequence appears to be that AutoCAD loads the AutoCAD Electrical code into memory first. Then it loads the stuff you’ve defined in the Startup Suite. If one of the latter has the same executable name as the former, then the latter one wins. Your custom utility will take precedence over the same-named AutoCAD Electrical one.

“Show Sigs” example

The stock “Show Sigs” command works by zooming extents and then displaying the temp graphics to show the source/destination links. But on a crowded drawing, you may want to zoom in to get a better view. The problem is that this erases the temp graphics. If you first zoom in and then launch the command, it zooms extents and then displays the graphics. You’re  screwed. Frustrating.

But if we create our own version of this with an ability to pan/zoom around and follow the paths, then it would be so much nicer. And if we give it the same executable name as the existing command in the UI and let it appload from the AutoCAD “Startup Suite”, then our own version will execute in place of the original when picked from the UI.

So, here’s the sequence:

1. Get the existing command name that is launched from the AutoCAD Electrical UI. Run the command one time. Then pick the “up arrow” key to “repeat the last command”. You should see the command name at the command prompt. It will likely have an “AE” prefix. For this example, it is “AESHOWSIG”.

2. Create your Lisp or VB version of the utility using this as the executable’s name. In lisp, your function name line of code would be something like this:

(defun c:AESHOWSIG ( / ) …

3.  Test your utility and adjust until you get it working as desired (this is the hard part!)

4. When finished, add your utility to the “Start-up Suite”. Type APPLOAD at the “Command:” prompt to display dialog as shown below.

Browse to your executable and add it to the list of executables to automatically load at AutoCAD  start-up (and with each subsequent drawing you open in AutoCAD).

That should do it. Restart AutoCAD Electrical. Now, selecting the “Show Signals” button on the stock AutoCAD Electrical UI should now invoke the new utility ( ! ). No change to the UI is needed in this case. To go back to the original, just remove this entry from the Startup Suite list.

If you want to see how this works, download the sample utility here.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: