;;; Copy selected objects into same place but in different (user defined) layer
;;; Based on routine created by BIGAL saved from: http://www.cadtutor.net/forum/showthread.php?98213-Copy-text-into-same-place-but-in-different-layer
;;; Deeply modified by Igal Averbuh 2018 (added option to copy any kind of objects and select layer to copy to)

(defun c:ccl ( / oldsnap ss x obj)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 167)

(setq oldclayer (getvar "clayer"))

(setq entlist (entget (car (entsel "\nSelect object to set layer as current: "))))
(setvar "clayer" (cdr (assoc 8 entlist)))
(princ "\n\nSelect Objects to Copy to current layer.")
(setq ss (ssget))
(repeat (setq x (sslength ss))
(setq obj (ssname ss (setq x (- x 1))))
(command "copy" obj "" "0,0" "0,0")
(command "chprop" "L" "" "layer" (cdr (assoc 8 entlist)) "")
)
(setvar "osmode" oldsnap)
(setvar "clayer" oldclayer)
(princ)
)
(c:ccl)

Advertisements