Jump to content

Lisp lệnh 9 trong chủ đề “Nhờ sửa lisp chuyển layer và hướng dẫn về array trong block dynamic”

^^ nhoc bỏ đại chạy thử thấy q63 ko bị đỗi thành Q8 :)

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/109369-nho-sua-lisp-chuyen-layer-va-huong-dan-ve-array-trong-block-dynamic/
;;************************Chuyen doi tuong ve dung layer

(defun CHANGE-LAYER (_TYPE LAYER / OBJS)
 (setq OBJS (ssget "X" (list (cons 0 _TYPE))))
 (if (not (tblsearch "layer" LAYER)) 
  (command ".layer" "m" LAYER "")
 );_ end if
 (command ".chprop" OBJS "" "la" LAYER "")
 (princ)
);_ end defun
(defun C:9 (/ OBJS)
(CHANGE-LAYER "DIMENSION" "---Q7-DIM")
;(CHANGE-LAYER "HATCH" "---Q8-HATCH")
(CHANGE-LAYER "*TEXT" "---Q9-TEXT")
(if (and (setq ss (ssget  "_x" '((0 . "HATCH") (-4 . "<not")(8 . "---Q63-LAT NEN")(-4 . "not>")))))
(command ".chprop" ss "" "la" "---Q8-HATCH" ""))
)

Cách dùng

  1. Tải tệp 309734_9.lsp về máy.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh 9 để chạy lisp.

Mã nguồn 309734_9.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/109369-nh%E1%BB%9D-s%E1%BB%ADa-lisp-chuy%E1%BB%83n-layer-v%C3%A0-h%C6%B0%E1%BB%9Bng-d%E1%BA%ABn-v%E1%BB%81-array-trong-block-dynamic/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/109369-nho-sua-lisp-chuyen-layer-va-huong-dan-ve-array-trong-block-dynamic/
;;************************Chuyen doi tuong ve dung layer

(defun CHANGE-LAYER (_TYPE LAYER / OBJS)
 (setq OBJS (ssget "X" (list (cons 0 _TYPE))))
 (if (not (tblsearch "layer" LAYER)) 
  (command ".layer" "m" LAYER "")
 );_ end if
 (command ".chprop" OBJS "" "la" LAYER "")
 (princ)
);_ end defun
(defun C:9 (/ OBJS)
(CHANGE-LAYER "DIMENSION" "---Q7-DIM")
;(CHANGE-LAYER "HATCH" "---Q8-HATCH")
(CHANGE-LAYER "*TEXT" "---Q9-TEXT")
(if (and (setq ss (ssget  "_x" '((0 . "HATCH") (-4 . "<not")(8 . "---Q63-LAT NEN")(-4 . "not>")))))
(command ".chprop" ss "" "la" "---Q8-HATCH" ""))
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Nhờ sửa lisp chuyển layer và hướng dẫn về array trong block dynamic. Xem đúng bài viết #309734 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 170)