.NET

.NET

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

Disable keyboard delete key on autocad loading

227 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 (194 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 (170 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 (162 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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.