Just checked and the ideas work on my computer and CAD which is odd.
(defun c:HPO (/ lst)
(setq lst '(("*outdoor*" "HPO-Outdoor")
("*building*" "HPO-Building")
("*setout*,*offset*" "HPO-Setout")
("bdy-stage*,bdy-design*,bdy,dp*,cp*,*stage*" "Bdy")
)
)
(foreach e lst (mergelayers (car e) (cadr e)))
(princ)
)
(defun mergelayers (match to / lst def lay)
(setq str "")
(or (tblsearch "LAYER" to)
(command "_.LAYER" "_N" to "")
)
(while (setq def (tblnext "LAYER" (null lay)))
(if (and (wcmatch (strcase (setq lay (cdr (assoc 2 def))))
(strcase match)
)
(not (wcmatch (strcase lay)
(strcat "*|*,0,DEFPOINTS," (strcase to))
)
)
)
(setq lst (cons lay lst))
)
)
(if lst
(progn
(command "_.LAYMRG")
(foreach e lst (command "_Name" e))
(command "" "_N" to "_Y")
)
)
(setq sel2 (ssget "_X"
'((-4 . "<or")
(8 . "*-HPO*")
(8 . "*Survey*")
(8 . "*Wall*")
(8 . "*U-*")
(8 . "*SCIMS*")
(8 . "Bdy-Tie")
(8 . "*Traverse*")
(8 . "*Fence*")
(8 . "*Road*")
(8 . "*Check*")
(8 . "*Chk*")
(-4 . "or>")
)
)
)
(sssetfirst nil sel2)
(if (= sel2 nil)
() ; if sel2 is a 'nil' selection, do nothing
(command "_erase" sel2 "") ; if sel2 is a selection, then erase it
)
)