(defun c:CHLAY (/ e n p)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n选择参考实体 :")))
(if e
(progn
(setq n (cdr (assoc 8 (entget e))))
(princ "\n选择需修改的实体 :")
(setq p (ssget))
(command "change" p "" "p" "la" n "")
)
(princ "错误! 未选到参考体!按回车继续 "))
(setvar "cmdecho" 1)
)

(defun C:openlay ()
(setvar "cmdecho" 0)
(command "layer" "on" "*" "")
(setvar "cmdecho" 1)
)

(defun c:CHLAY1 (/ e n p ea a2)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n选择参考图层实体 :")))
(setq ea (car (entsel "\n选择需修改的图层实体 :")))
(if e
(progn
(setq n (cdr (assoc 8 (entget e))))
(setq a2 (cdr (assoc 8 (entget ea))))
(setq p (ssget "Y" (list (cons 8 a2))))
(command "change" p "" "p" "la" n "")
)
(princ "错误! 未选到参考体!按回车继续 "))
(setvar "cmdecho" 1)
)

(defun C:openlay ()
(setvar "cmdecho" 0)
(command "layer" "on" "*" "")
(setvar "cmdecho" 1)
)

(defun c:CHLAY2 (/ e n p ea a2)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n选择需删除的图层实体 :")))
(if e
(progn
(setq n (cdr (assoc 8 (entget e))))
(setq p (ssget "X" (list (cons 8 n))))
(command "erase" p "" )
)
(princ "错误! 未选到参考体!按回车继续 "))
(setvar "cmdecho" 1)
)

(defun C:openlay ()
(setvar "cmdecho" 0)
(command "layer" "on" "*" "")
(setvar "cmdecho" 1)
)

(defun c:byl()
;(setvar "cmdecho" 0)
(princ "\n选择需修改的实体 :")
(setq p (ssget))
(command "change" p "" "p" "c" "bylayer" "")
;(setvar "cmdecho" 1)
)

(defun c:setlay (/ e n)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n选择图层所在的实体 :")))
(if e
(progn
(setq n (cdr (assoc 8 (entget e))))
(command "layer" "s" n "")
)
(princ "\n没有选到实体!按回车继续."))
(setvar "cmdecho" 1)
)

(DEFUN C:LED (/ X I ENTCN A1 W1 B1 E E1)
(setvar "cmdecho" 0)
(SETQ E (SSGET))
(SETQ ENTCN (SSLENGTH E))
(SETQ I 0)
(INITGET I "W L")
(SETQ X (GETKWORD "W多义线/L直线:"))
;(INITGET (+ 24))
(SETQ W1 (GETREAL "输入线宽:"))
(WHILE (< I ENTCN)
(SETQ A (SSNAME E I))
(SETQ B1 (ENTGET A))
(SETQ E1 (ASSOC 0 B1))
(SETQ A1 (ASSOC -1 B1))
(SETQ A1 (CDR A1))
(COND ((AND (= X "L")(= "LINE" (CDR E1)))
(COMMAND "PEDIT" A1 "Y" "W" W1 "X"))
((AND (= X "W")(= "POLYLINE" (CDR E1)))
(COMMAND "PEDIT" A1 "W" W1 "X")))
(SETQ I (+ I 1)))
(setvar "cmdecho" 1)
)

(defun c:ly (/ la co lt blk)
(setvar "cmdecho" 0)
(setq la (getstring "\n输入图层名称:"))
(setq co (getstring "\n输入图层颜色或色号:<White>"))
(if (null y1)(setq y1 7))
(setq lt (getstring "\n输入图层线型(全名):<continuous>"))
(if (null lt)(setq lt continuous))
(entdel (setq blk (entlast)))
(command "layer" "m" la "c" co "" "lt" lt "" "")
(entdel blk)
(setvar "cmdecho" 1)
)
(setq w2 45)
(DEFUN C:LEA (/ E ENTCN I X W1 A B1 E1 A1)
(prompt "\n 选择多义线直线或圆弧:")
(SETQ E (SSGET))
(SETQ ENTCN (SSLENGTH E))
(SETQ I 0)
(INITGET I "W L A")
(SETQ X (GETKWORD "W多义线/L直线/A圆弧:"))
(princ "\n输入线宽<")
(princ w2)
(SETQ W1 (GETINT ">:"))
(if (/= W1 nil)(setq w2 W1)(SETQ W1 w2))
(setvar "cmdecho" 0)
(WHILE (< I ENTCN)
(SETQ A (SSNAME E I))
(SETQ B1 (ENTGET A))
(SETQ E1 (ASSOC 0 B1))
(SETQ A1 (ASSOC -1 B1))
(SETQ A1 (CDR A1))
(COND ((AND (= X "L")(= "LINE" (CDR E1)))
(COMMAND "PEDIT" A1 "Y" "W" W1 "X"))
((AND (= X "W")(= "POLYLINE" (CDR E1)))
(COMMAND "PEDIT" A1 "W" W1 "X"))
((AND (= X "A")(= "ARC" (CDR E1)))
(COMMAND "PEDIT" A1 "Y" "W" W1 "X")))
(SETQ I (+ I 1)))
(setvar "cmdecho" 1)
)

(defun c:LEB (/ c m n w1 cl e0 e)
(setvar "cmdecho" 0)
(prompt "\n 选择多义线直线或圆弧:")
(setq c (ssget))
(setq m (sslength c))
(setq n 0)
(initget 5)
(setq W1 (getint "\n 输入线宽:"))
(repeat m
(setq cl (ssname c n))
(setq e0 (entget cl))
(setq e (cdr (assoc 0 e0)))
(if (/= e "POLYLINE")
(progn
(command "pedit" cl "y" "w" W1 "x")
)
)
(if (= e "POLYLINE")
(progn
(command "pedit" cl "w" W1 "x")
)
)
(setq n (+ 1 n)))
(setvar "cmdecho" 1)
)

(defun c:frelay (/ e h)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n选择图层所在的实体 :")))
(if e (progn
(setq h (cdr (assoc 8 (entget e))))
(command "layer" "f" h "" Y "")
)
(princ "\n没有选到实体!按回车继续."))
(setvar "cmdecho" 1)
)

(defun c:locklay (/ e h)
(setvar "cmdecho" 1)
(setq e (car (entsel "\n选择图层所在的实体 :")))
(if e (progn
(setq h (cdr (assoc 8 (entget e))))
(command "layer" "LO" h "")
)
(princ "\n没有选到实体!按回车继续."))
(setvar "cmdecho" 1)
)

(defun C:ual ()
(setvar "cmdecho" 0)
(command "layer" "u" "*" "")
(setvar "cmdecho" 1)
)

(defun c:unlock (/ e h)
(setvar "cmdecho" 1)
(setq e (car (entsel "\n选择图层所在的实体 :")))
(if e (progn
(setq h (cdr (assoc 8 (entget e))))
(command "layer" "u" h "" Y "")
)
(princ "\n没有选到实体!按回车继续."))
(setvar "cmdecho" 1)
)

(defun C:thawall ()
(setvar "cmdecho" 0)
(command "layer" "th" "*" "")
(setvar "cmdecho" 1)
)

(defun c:sw (/ e n)
(setvar "cmdecho" 0)
(setq e (car (entsel "\n在图中选择文字实体 :")))
(if e
(progn
(setq n (cdr (assoc 7 (entget e))))
(setvar "filedia" 0)
(command "style" n "" "" "" "" "" ""))
(princ "\n没有选到实体!按回车继续."))
(setvar "cmdecho" 1)
(setvar "filedia" 1)
)

(defun c:offlay (/ e h)
  (setvar "cmdecho" 0)
  (setq e (car (entsel "\n选择图层所在的实体 :")))
  (if e (progn
          (setq h (cdr (assoc 8 (entget e))))
          (command "layer" "off" h "" ""))
        (princ "\n没有选到实体!按回车继续.")
  )
  (setvar "cmdecho" 1)
)
