prevent deletion?

Discussion in 'AutoCAD' started by Ledi, Nov 30, 2004.

  1. Ledi

    Ledi Guest

    Hi!

    Is there a way to prevent deleting objects with VBA?

    Private Sub AcadDocument_ObjectErased(ByVal ObjectID As Long)
    ???
    end sub
     
    Ledi, Nov 30, 2004
    #1
  2. Ledi

    lorier Guest

    I don't know, but maybe if objectid = "12345" then send an undo or redraw. Or if its on its own layer you can lock the layer.
     
    lorier, Dec 1, 2004
    #2
  3. Ledi

    Jimmy D Guest

    Hi Ledi,

    if you want to completely ignore the "erase" command, try

    Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    If CommandName = "ERASE" Then
    MsgBox "Command is not allowed", vbCritical
    ThisDrawing.SendCommand Chr(3) 'break command with ESC
    End If
    End Sub

    Jimmy
     
    Jimmy D, Dec 1, 2004
    #3
  4. Ledi

    Ledi Guest

    But then i dont know on which object the delete is performed.

    I think that i'm going to try something with ObjectARX in this case.

    thank you
     
    Ledi, Dec 2, 2004
    #4
  5. Ledi

    Ledi Guest

    i found the solution, this works for me

    Public COMM As String

    Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    'MsgBox "Begin: " & CommandName
    COMM = CommandName
    End Sub

    Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    'MsgBox "End: " & CommandName
    COMM = ""
    End Sub

    Private Sub AcadDocument_ObjectErased(ByVal ObjectID As Long)
    'MsgBox LUZ_X.UnErase(ObjectID)
    If COMM = "ERASE" Then
    MsgBox "HALO: " & ObjectID
    ThisDrawing.SendCommand "UNDO 1 "
    End If
    End Sub
     
    Ledi, Dec 6, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.