Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Override Existing AutoCAD commands

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
kpennell
3987 Views, 4 Replies

Override Existing AutoCAD commands

Good day all,

 

I was just wondering, if there was a way to override existing AutoCAD commands.

 

The following example is very extreme, and would be malicious if someone actually set it up that way, I'm just looking for way ways to improve production, without too much interference on many many machines.

 

Lets try this.  When a user types "line" at the command prompt, or hits the "line" button on the toolbar, or chooses "line" from the draw pulldown menu, is there any way I can re-write what line means and draw a circle?  (Extreme example)

 

There are just some commands that I'd like to have a variable set in the background, depending on what the command is.  So I'm thinking if I could re-write the "line" command, instead of trying to convince everyone to use and remember a custom command, it would be much more efficient.  There are lisp files already loaded in their start-up suite.  Not sure if that helps.

 

Thanks

KP

4 REPLIES 4
Message 2 of 5
dbroad
in reply to: kpennell

Yes.  It is possible.  Give a useful rather than a malicious one if you want an example.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 5
RStillwell
in reply to: kpennell

Undefine the LINE command at startup and replace it with your custom LINE command.

 

The default LINE command can still be issued by using .LINE

Message 4 of 5
Kent1Cooper
in reply to: kpennell


@kpennell wrote:

.... 

I was just wondering, if there was a way to override existing AutoCAD commands.

....


Yes.  A more innocuous example -- say you always wanted all Polylines to default to a 1-drawing-unit global width, no matter what.  You can make a file called, for example, PL1.lsp, containing something like this:
 

(command "_.undefine" "PLINE")
(defun C:PLINE ()

  (setvar 'plinewid 1)

  (command "_.pline")

)
 

It will set the width to 1 every time the User goes for the PLINE command or the PL shortcut.  They could still set a different width, but it would revert to 1 every time -- it wouldn't remember their previous setting as the base PLINE command does.

 

Note the period/decimal in "_.pline", to force it to dig back into the core AutoCAD command once it has set the width.  You can include the underscore character or not [it makes it work in other-than-English-language versions].

 
Put this in your acaddoc.lsp file to have it loaded, and the command therefore redefined, with every drawing that's opened:

 

(load "PL1")

 

Other and fancier controls can be added [dealing with the CMDECHO System Variable, for instance, or feeding out a notification that the command has been redefined], but that's the core of the operation.

Kent Cooper, AIA
Message 5 of 5
kpennell
in reply to: Kent1Cooper

Thanks all.

 

My apologies for exagerating the example.  Sometimes when posting, you have to exagerate to make sure you get the point across, rather than going back and forth with  "well I meant to say" or "close but that's not what I was thinking".

 

Ther real situation is:

 

When a user is in a certain drawing of a certain folder, I want the line, circle command to change to a layer that is visible in the current viewport.

 

We have a lot of short-cut commands devleoped, and folks can't remember everything.  It's a quality assurance measure and speedier production.  It's fine that I can reassign "L" at the command prompt, but folks still like to use toolbars and menu pulldowns.

 

Thanks much.

KP

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost