Jump to content

Recommended Posts

Posted (edited)

Currently if the variable PICKFIRST is set to 1 and the user selects objects and presses the key on the keyboard, the command "_.erase" is sent to AutoCAD which then deletes the selected objects.

 

I want to change the command that is sent to AutoCAD when the key is pressed from "_.erase" to the simpler "erase" command but I cannot figure out where I can do this or if it is even possible.

 

The reason I'm doing this is to support an idea I have to add Xdata to objects to mark them as objects that can't be deleted. To support this, I've written code that undefines the "ERASE" command then redefines it with my Xdata code check then finishes with the real erase command of:

 

(command "_.erase")

Does anyone know if it is possible to change what command is sent to AutoCAD when the key is pressed?

 

I'm using AutoCAD 2013 on Windows 7 64-bit. Thanks.

 

EDIT: I forgot to mention that my code works fine if the user uses the "ERASE" button from the ribbon or types in either "E" or "ERASE". It's just when the user presses the key that my code is circumvented so I'm just trying to prevent this.

Edited by lfe011969
Additional clarification
Posted

FWIW -

 

The _.ERASE and ERASE Commands are the same, technically, the prefixes simply ensure that you use the English, and Default Command version (in case someone has undefined, etc.).

 

You cannot 'mark' entities to prevent deletion... However, you can implement Object Reactors to automagically recreate the associated entities upon deletion. This gives the user the 'illusion' that they cannot delete the entity... Funny facial expressions ensue. :thumbsup:

Posted
The _.ERASE and ERASE Commands are the same, technically, the prefixes simply ensure that you use the English, and Default Command version (in case someone has undefined, etc.).

 

This is exactly what I've done. I have undefined the "ERASE" command to use my Xdata check code then I call the ".ERASE" command to access AutoCAD's normal "ERASE" command. I included the underscore in my original post because that is how the command is invoked when I press the key on my keyboard.

 

You cannot 'mark' entities to prevent deletion...

 

I do not agree as my code works with the ERASE command redefined. When one of our users tries to delete a block with and the appropriate Xdata they get a message box saying, "You cannot delete this entity!!"

Posted

If memory serves, you cannot 'redefine' the Delete key in AutoCAD, specifically using Shortcut Keys, or Temporary Overrides.

 

I do not agree as my code works with the ERASE command redefined. When one of our users tries to delete a block with and the appropriate Xdata they get a message box saying, "You cannot delete this entity!!"

 

If that's how you want it to work, so be it... That's certainly more work than is necessary for the same result, IMHO.

 

Happy coding

Posted
If memory serves, you cannot 'redefine' the Delete key in AutoCAD, specifically using Shortcut Keys, or Temporary Overrides.

 

I was afraid of that. I just wish I could find some webpage or other reference material that specifically says so because I feel this is something that we should be able to do. As far as using reactors, I just don't understand how to use them too well so I try to avoid them.

 

Thanks for your input.

Posted

I was afraid of that. I just wish I could find some webpage or other reference material that specifically says so because I feel this is something that we should be able to do.

 

For completeness, one cannot use just Delete for Shortcut Keys... However, the documentation does specify that Ctrl + Delete, and Ctrl + Shift + Delete are accepted.

 

 

To create or modify a shortcut key

 

 

6. Hold down the modifier key Ctrl with a combination of Shift and Alt if desired and press a letter, number, function, or virtual key such as F1 or Insert. Valid modifier and key combinations include the following:

  • Function (Fn) keys containing no modifiers
  • Number Pad (NUMPADn) keys containing no modifiers
  • Ctrl+letter, Ctrl+number, Ctrl+function, Ctrl+virtual key
  • Ctrl+Alt+letter, Ctrl+Alt+number, Ctrl+Alt+function, Ctrl+Alt+virtual key
  • Ctrl+Shift+letter, Ctrl+Shift+number, Ctrl+Shift+function, Ctrl+Shift+virtual key
  • Ctrl+Shift+Alt+letter, Ctrl+Shift+Alt+number, Ctrl+Shift+Alt+function, Ctrl+Shift+Alt+virtual key

 

Note: The virtual keys that are supported are Escape, Insert, Delete, Home, End, Page Up, Page Down, Left Arrow, Right Arrow, Up Arrow, and Down Arrow. The virtual key Escape can only be used by itself or with the modifier combination Ctrl+Shift+Alt.

 

More information can be found here.

 

 

As far as using reactors, I just don't understand how to use them too well so I try to avoid them.

 

They can be quite perplexing until you better understand of some common Object Oriented development concepts... Mainly that Objects have Properties, Methods, and Events, etc..

 

In short, a Visual LISP Reactor is nothing more than a 'hallway monitor' that watches for specific Events. Reactors must follow some very specific rules to perform correctly, which is one of the reasons that many LISP-ers do not pursue them. These concepts become ever more simple to understand as (if?) you pursue higher level .NET languages for develpment (i.e., C++, C#, F#, VB, etc.).

 

Perhaps we'll revisit this, using Reactors, sometime soon... Cheers :beer:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...