.NET

Reply
Valued Contributor
scluna
Posts: 61
Registered: ‎02-20-2007
Message 1 of 4 (223 Views)
Accepted Solution

Disable keyboard delete key on autocad loading

223 Views, 3 Replies
03-13-2014 01:49 PM

Hi,

 

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

 

Thanks and regards,

SCLuna

I think I found the solutions to do this by implementing

ObjectOverrule

Valued Contributor
scluna
Posts: 61
Registered: ‎02-20-2007
Message 2 of 4 (190 Views)

Re: Disable keyboard delete key on autocad loading

03-14-2014 02:04 PM in reply to: scluna

I think I found the solutions to do this by implementing

ObjectOverrule

SCLuna
Valued Contributor
swaywood
Posts: 91
Registered: ‎08-22-2013
Message 3 of 4 (166 Views)

Re: Disable keyboard delete key on autocad loading

03-14-2014 11:37 PM in reply to: scluna
could you post your key code showing how to realize this?
Valued Contributor
scluna
Posts: 61
Registered: ‎02-20-2007
Message 4 of 4 (158 Views)

Re: Disable keyboard delete key on autocad loading

03-15-2014 07:47 AM in reply to: swaywood

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

SCLuna
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!