(defun c:of (/ ent dist2 dist obj kwrd)

(vl-load-com) ;<-good!

(while (not ent) ;<- this sort of loop is hard to get out of, see my code

(if (eq (setq ent (car (entsel "\nSelect object to offset: "))) ;<- (if (not (setq...)))

nil ;<- testing for nil is unneeded, use LISP's return values directly

)

(princ "\nThat object was not an appropriate. Please select again: ") ;<- what if I pick a circle?

)

)

(initget (+ 1 2 4 64)) ;<- use of the Z-blocker was nice

(setvar "osmode" 167)

(setvar "ORTHOMODE" 0)

(setq dist (getdist "\nEnter one side offset distance: "))

(setq dist2 (getdist "\nEnter other side offset distance:"))

(initget (+ 2 4) "Yes No") ;<- bits 2 and 4 server no purpose in (getkword)

(setq kwrd (getkword "\nDelete original object [Yes/No] : ")) ;<- 2000-style options, good!

(if (/= kwrd "Yes") ;vla-object ent))

(vla-offset obj dist)

(vla-offset obj (* dist2 -1))

(if (eq kwrd "Yes") ;<- (/= kwrd "No")

(vla-erase obj)

)

(princ)
)
(c:of)

Advertisements