Hi,
Here you go.
Code:
(defun c:Test (/ *error* lst doc lck sel ent get)
;;------------------------------------;;
;; Author: Tharwat - Date: 30.Jun.2017;;
;; Move objects from layer to another ;;
;; as indicated in the 'lst' variable.;;
;; ;;
;;------------------------------------;;
(defun *error* (msg)
(and doc (vla-endundomark doc))
(if lck (mapcar '(lambda (u) (vla-put-lock u :vlax-true)) lck))
(and msg (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*,*BREAK*"))
(princ (strcat "\nError =>: " msg))
)
(princ)
)
;; ;;
(setq lst '(("UG_CONDUIT_NEW" "UG_CONDUIT_EXIST")
("UG_HV_NEW" "UG_HV_EXIST")
("TEXT_2.5_NEW" "TEXT_2.5_EXIST")
("UG_LV_NEW" "UG_LV_EXIST")
("UG_PL_NEW" "UG_PL_EXIST")
("UG_LVS_NEW" "UG_LVS_EXIST")
("ASSETS_NEW" "ASSETS_EXIST")
)
doc (vla-get-activedocument (vlax-get-acad-object))
)
(vlax-for layer (vla-get-layers doc)
(if (eq :vlax-true (vla-get-lock layer))
(vla-put-lock (car (setq lck (cons layer lck))) :vlax-false)
)
)
;; ;;
(vla-endundomark doc)
(vla-startundomark doc)
(if (setq sel (ssget "_X" (list (cons 8 (apply 'strcat
(mapcar (function (lambda (x) (strcat x ",")))
(mapcar 'car lst)
)
)
)
)
)
)
(while (setq ent (ssname sel 0))
(entmod (subst
(cons 8 (cadr (assoc (cdr (assoc 8 (setq get (entget ent)))) lst)))
(assoc 8 get)
get
)
)
(ssdel ent sel)
)
)
(*error* nil)
(princ)
) (vl-load-com)