NASA 发表于 2005-8-2 09:07

图层控制 lisp,图层管理工具

本帖最后由 wdhd 于 2016-3-30 09:17 编辑

  ;laymod.lsp

  ;__________________________

  ;解决R14“bonus”工具的移植

  ;图层管理工具

  ; left2r

  ;2004.12.18

  ;lleft@126.com

  ;浙江杭州

  ;-------------------------------------------

  ;图层对象选择,将标注归入dim层,文字归入txt层

  ;___________________________________________

  (defun C:laymod(/ lm_ssd lm_sst)

  (if (not (tblsearch "layer" "DIM"))

  (command "-layer" "n" "DIM" "c" "1""DIM"""));endif

  (if (not (tblsearch "layer" "TXT"))

  (command "-layer" "n" "TXT" "c" "1""TXT"""));endif

  (setq lm_ssd (ssget "X" '((0 . "DIMENSION")))

  lm_sst (ssget "X" '((-4 . ""))));endsetq

  (if lm_ssd (command "chprop" lm_ssd "" "la" "DIM"""))

  (if lm_sst (command "chprop" lm_sst "" "la" "TXT"""))

  );end defun

  ;-------------------------------------

  ;图层孤立显示,通过选择对象单显某图层

  ;_____________________________________

  (defun C:layiso(/ l9_ss l9_ent l9_lay ii)

  (setq l9_ss "" ii 0)

  (princ "\n选择要保留显示的图层:")

  (setq l9_ss (ssget))

  (if l9_ss (command "-layer""off""*""y"""))

  (repeat (sslength l9_ss)

  (setq l9_ent (entget (ssname l9_ss ii)))

  (setq l9_lay (cdr (assoc 8 l9_ent)) ii (1+ ii))

  (command "-layer""on" l9_lay "")

  );end repeat

  );end defun layiso

  ;--------------------------

  ;打开所有图层

  ;__________________________

  (defun C:layon()(command "-layer""on""*"""))

  ;--------------------------

  ;解除所有图层锁定

  ;__________________________

  (defun C:layul()(command "-layer""u""*"""))

  ;--------------------------

  ;解除所有图层冻结

  ;__________________________

  (defun C:layuk()(command "-layer""t""*"""))

  ;--------------------------

  ;通过选择解除图层锁定

  ;__________________________

  (defun C:layulk(/ l9_ss l9_ent l9_lay)

  (setq l9_ss (entsel "\n选择要解锁的图层:"))

  (while l9_ss

  (setq l9_ent (entget (car l9_ss)))

  (setq l9_lay (cdr (assoc 8 l9_ent)))

  (command "layer""u" l9_lay"")

  (setq l9_ss (entsel "\n选择要解锁的图层:"))

  );end while

  );end defun

  ;--------------------------

  ;通过选择锁定图层

  ;__________________________

  (defun C:laylck(/ l9_ss l9_ent l9_lay)

  (setq l9_ss (entsel "\n选择要锁定的图层:"))

  (while l9_ss

  (setq l9_ent (entget (car l9_ss)))

  (setq l9_lay (cdr (assoc 8 l9_ent)))

  (command "layer""u" l9_lay"")

  (setq l9_ss (entsel "\n选择要锁定的图层:"))

  );end while

  );end defun

  ;--------------------------

  ;通过选择冻结图层

  ;_________________

  (defun C:layfrz(/ l9_ss l9_ent l9_lay l9_clay ii)

  (setq l9_clay (getvar "clayer"))

  (princ "\n选取冻结图层参考对象: ")

  (setq l9_ss (ssget))

  (setq ii 0)

  (command "-layer")

  (repeat (sslength l9_ss)

  (setq l9_ent (entget (ssname l9_ss ii)))

  (setq l9_lay (cdr (assoc 8 l9_ent)))

  (command "f" l9_lay)

  (setq ii (1+ ii))

  );end repeat

  (command "")

  );end defun layfrz

  ;--------------------------

  ;通过选择隐藏图层

  ;__________________________

  (defun C:layoff(/ l9_ss l9_ent l9_lay l9_clay ii)

  (princ "\n选取隐藏图层参考对象: ")

  (setq l9_ss (ssget))

  (setq l9_clay (getvar "clayer"))

  (setq ii 0)

  (command "-layer")

  (repeat (sslength l9_ss)

  (setq l9_ent (ssname l9_ss ii))

  (setq l9_lay (cdr (assoc 8 (entget l9_ent))))

  (if (/= l9_lay l9_clay)

  (command "off" l9_lay)(command "off" l9_lay"y")

  );end if

  (setq ii (1+ ii))

  );end repeat

  (command "")

  );end defun layoff

  ;--------------------------

  (princ "\n---------->> 图层调整

  (laymod)layiso/layon/layuk/layulk/laylck/layfrz/layoff<<----------")

  (prin1)

06050510 发表于 2006-8-11 09:48

怎么全是编程内容
页: [1]
查看完整版本: 图层控制 lisp,图层管理工具