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
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by RStillwell. Go to Solution.
Solved by dbroad. Go to Solution.
Yes. It is possible. Give a useful rather than a malicious one if you want an example.
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
@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.
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