@3dwannab
A couple more notes:
1) setting "NOMUTT" is unnecessary and removes your program prompts from the command line, while it has no effect on the HATCHEDIT command. Makes it confusing.
2) Your loop structure forces a hard exit from the "Pickone" option, better to change to a different loop to avoid this.
3) you should check for missed picks in the (entsel) using errno system variable.
FWIW, this is how I would write the code.
(defun c:HH_Origin_Location (/ acdoc ans ent *error* oecho oosnh pt px py pnew ss)
; Local error function
(defun *error* (errmsg)
(and acDoc (vla-EndUndoMark acDoc))
(and errmsg
(not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
(princ (strcat "\n<< Error: " errmsg " >>\n"))
)
(setvar 'cmdecho oecho)
(setvar 'osnaphatch oosnh)
(princ)
)
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))
oecho (getvar 'cmdecho)
oosnh (getvar 'osnaphatch)
)
(or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))
(setvar 'cmdecho 0)
(setvar 'osnaphatch 1)
(initget "bottomLeft bottomRight toprIght toplEft Center Pickone pickAll Offset")
(if (not (setq ans (getkword "\nChoose hatch location: [bottom Left/bottom Right/top rIght/top lEft/Center/Pick one/pick All/Offset] <Pick one>: ")))
(setq ans "Pickone")
)
(if (= ans "Pickone")
(while
(progn
(setvar "errno" 0)
(setq ent (entsel "\n\nSelect Hatch <Exit>: "))
(cond
((= 7 (getvar "errno"))(princ "\nNo Object Selected. Try Again...\n"))
((vl-consp ent)
(if (/= (cdr (assoc 0 (entget (car ent)))) "HATCH")
(princ "\nInvalid Object Selected. Please Select a HATCH Object. ")
(progn
(if (setq pt (getpoint "\nNew hatch origin: "))
(progn
(command "_.HatchEdit" (car ent) "_O" "_S" "_non" pt "_Y")
(setq ss (if ss (ssadd (car ent) ss) (ssadd (car ent))))
)
(princ "\nNo Point Selected. Please restart Selection. ")
)
T
)
)
)
)
)
)
(progn
(cond
((= ans "pickAll")(setq pt (getpoint "\nNew hatch origin: ")))
((= ans "Offset")(setq pt (getpoint "\nOffset by (x,y): ")))
)
(if (and (or (not (wcmatch ans "pickAll,Offset")) pt)
(progn (princ "\nSelect Hatch Objects: ")(setq ss (ssget "_:L" '((0 . "HATCH")))))
)
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i))))
(cond
((= ans "bottomLeft")(command-s "_.HatchEdit" ent "_O" "_D" "_L" "_Y"))
((= ans "bottomRight")(command-s "_.HatchEdit" ent "_O" "_D" "_R" "_Y"))
((= ans "toprIght")(command-s "_.HatchEdit" ent "_O" "_D" "_I" "_Y"))
((= ans "toplEft")(command-s "_.HatchEdit" ent "_O" "_D" "_E" "_Y"))
((= ans "Center")(command-s "_.HatchEdit" ent "_O" "_D" "_C" "_Y"))
((= ans "pickAll")(command-s "_.HatchEdit" ent "_O" "_S" "_non" pt "_Y"))
((= ans "Offset")
(setq el (entget ent)
pX (cdr (assoc 43 el))
pY (cdr (assoc 44 el))
pNEW (mapcar '+ pt (list pX pY 0))
)
(command-s "_.HatchEdit" ent "_O" "_S" "_non" pNEW "_Y")
)
)
)
)
)
)
(if ss (princ (strcat "\n " (itoa (sslength ss)) (if (> (sslength ss) 1) " hatches" " hatch") " changed using " ans " option. ")))
(*error* nil)
(princ)
)