I'm assuming you are learning so I'll leave some notes for you.
(defun c:offset_and_delete (/ dist ent)
(setq dist (getdist "\nEnter offset distance in feet: "))
;none of this is needed. Just use an initget to check if it is a valid entry.
;vvvvvvvvvvv
(if (not dist)
(progn
(princ "\nInvalid distance.")
(exit)
)
;^^^^^^^^
;instead of converting the distance to feet after it has been set, just convert it at the same time
;for example, (setq dist (*(getdist \n do distance: ")12))
(setq dist (* dist 12.0)) ; Convert feet to inches
;instead of quitting the routine when the entity is missed, loop the part where you select
;until you have a valid selection
(setq ent (car (entsel "\nSelect object to offset: ")))
(if (not ent)
(progn
(princ "\nNo object selected.")
(exit)
)
(progn
;The order of this command is wrong, its distance->Object->Direction
;Just run through the command in AutoCAD and take note of the order.
(command "_.OFFSET" ent "" dist)
;You need to set a variable Yes or No and then check it.
;Look at updated code for example.
(if (y-or-n-p "\nDelete original object? ")
(command "_.ERASE" ent "")
)
)
)
)
(princ)
)
Here's my version, seems to work as you want.
(defun c:ODEL (/ dist ent side del)
(initget 7)
(setq dist (*(getdist "\nEnter offset distance in Feet: ")12))
(while
(not ent)
(setvar 'errno 0)
(setq ent (car (entsel "\nSelect object to offset: ")))
(and (= 7 (getvar 'errno))
(princ "\nNo Entity Selected!")
)
)
(setq side (getpoint "\n Pick Offset Direction"))
(command "_.OFFSET" dist ent side "")
(initget "Yes, No")
(setq del (getkword "\nDelete original object? [Yes/No]: "))
(if (= del "Yes")
(command "_.ERASE" ent "")
)
(princ)
)