Disable keyboard delete key on autocad loading

Disable keyboard delete key on autocad loading

Anonymous
Not applicable
1,367 Views
3 Replies
Message 1 of 4

Disable keyboard delete key on autocad loading

Anonymous
Not applicable

Hi,

 

Does anyone ehere knows how to disable keyboards keys (e.g. delete key, enter key, spacebar key) once autocad load.

 

Thanks and regards,

0 Likes
Accepted solutions (1)
1,368 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

I think I found the solutions to do this by implementing

ObjectOverrule

0 Likes
Message 3 of 4

swaywood
Collaborator
Collaborator
could you post your key code showing how to realize this?
0 Likes
Message 4 of 4

Anonymous
Not applicable

Here is the code I got from reading an article from dev blog but I forgot the link.

 

Public Class CErase
        Inherits ObjectOverrule
        Public Overrides Sub [Erase](dbObject As DBObject, erasing As Boolean)
            MyBase.[Erase](dbObject, erasing)
            Throw New Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NotApplicable, "Use DrawingTool Delete command to delete Spaces.")
        End Sub
    End Class

    Shared objEraseOverRule As EraseOverrule = Nothing

    Public Shared Sub PreventErase()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        If objEraseOverRule Is Nothing Then
            objEraseOverRule = New EraseOverrule()

            ObjectOverrule.AddOverrule(RXObject.GetClass(GetType(Entity)), objEraseOverRule, False)
            ObjectOverrule.Overruling = True
        Else
            ObjectOverrule.RemoveOverrule(RXObject.GetClass(GetType(Entity)), objEraseOverRule)
            objEraseOverRule.Dispose()
            objEraseOverRule = Nothing
        End If
    End Sub

0 Likes