VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deleted Items

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
177 Views, 2 Replies

Deleted Items

Is there a programmatic way to recover deleted items (without using the undo
command). For example, if an object handle is known?

Thank you very much,
Edward
2 REPLIES 2
Message 2 of 3
Ed.Jobe
in reply to: Anonymous

Lisp is the only way I know of. If you know the hanle pass it to the (handent) function, which returns an ename. Pass that to the (entdel) function. If the entity is already deleted, (entdel) undeletes it. Works in the current editing session only. Here's what I have. It requires VLAX.cls from acadx.com.

Sub test()
Dim oEnt As AcadEntity
Dim pp As Variant
Dim lHandle As Long
ThisDrawing.Utility.GetEntity oEnt, pp
lHandle = oEnt.Handle
oEnt.Delete
UndeleteObjectByHandle lHandle
End Sub

Public Sub UndeleteObjectByHandle(Handle As Long)
'bring back deleted object
'by calling (entdel) with the object's handle.
Dim lispstr As String
Dim VL As New VLAX

lispstr = "(entdel (handent """ & Handle & """))"
VL.EvalLispExpression lispstr
End Sub

Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 3
Anonymous
in reply to: Anonymous

thanks!


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Lisp
is the only way I know of. If you know the hanle pass it to the (handent)
function, which returns an ename. Pass that to the (entdel) function. If the
entity is already deleted, (entdel) undeletes it. Works in the current editing
session only. Here's what I have. It requires VLAX.cls from acadx.com.
 
Sub test()
    Dim oEnt As AcadEntity
    Dim pp As Variant
    Dim lHandle As Long
    ThisDrawing.Utility.GetEntity oEnt, pp
    lHandle = oEnt.Handle
    oEnt.Delete
    UndeleteObjectByHandle lHandle
End Sub

Public Sub UndeleteObjectByHandle(Handle As Long)
    'bring back deleted object
    'by calling (entdel) with the object's handle.
    Dim lispstr As String
    Dim VL As New VLAX

lispstr = "(entdel (handent """ & Handle & """))"
    VL.EvalLispExpression lispstr
End Sub

Public Function Ent2lspEnt(entObj As AcadEntity) As String
    'Designed to work with SendCommand, which can't pass objects.
    'This gets an objects handle and converts it to a string
    'of lisp commands that returns an entity name when run in SendCommand.
    Dim entHandle As String
    entHandle = entObj.Handle
    Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost