Jump to content

Về Lisp chọn nhanh đối tượng Block

Không có máy test. Thử xem:


;----- Chon tap hop blocks dynamic theo ten cua tap hop blocks dynamic mau.
(defun C:SB1 ( / i str ent)
 (setq i 2 str (cdr (assoc 2 (entget (car (entsel (strcat "\nChon Block mau 1: ")))))))
 (while (setq ent (car (entsel (strcat "\nChon Block mau " (itoa i) ": "))))
 (setq str (strcat str "," (cdr (assoc 2 (entget ent)))))
 (setq i (1+ i)))
 (princ "\nChon cac Block can thong ke...")
 (setq ss (ssget (list (cons 0 "INSERT") (cons 2 str))))
 (repeat (setq n (sslength ss))
  (setq n (1- n) ent (ssname ss n))
  (if (eq (vla-get-IsDynamicBlock (vlax-ename->vla-object ent)) :vlax-false)
   (ssdel ent ss)))
 (sssetfirst nil ss))

Cách dùng

  1. Tải tệp 437552_sb1.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 SB1 để chạy lisp.

Mã nguồn 437552_sb1.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/176581-nh%E1%BB%9D-ch%E1%BB%89nh-s%E1%BB%ADa-lisp-v%E1%BB%81-lisp-ch%E1%BB%8Dn-nhanh-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-block/

;----- Chon tap hop blocks dynamic theo ten cua tap hop blocks dynamic mau.
(defun C:SB1 ( / i str ent)
 (setq i 2 str (cdr (assoc 2 (entget (car (entsel (strcat "\nChon Block mau 1: ")))))))
 (while (setq ent (car (entsel (strcat "\nChon Block mau " (itoa i) ": "))))
 (setq str (strcat str "," (cdr (assoc 2 (entget ent)))))
 (setq i (1+ i)))
 (princ "\nChon cac Block can thong ke...")
 (setq ss (ssget (list (cons 0 "INSERT") (cons 2 str))))
 (repeat (setq n (sslength ss))
  (setq n (1- n) ent (ssname ss n))
  (if (eq (vla-get-IsDynamicBlock (vlax-ename->vla-object ent)) :vlax-false)
   (ssdel ent ss)))
 (sssetfirst nil ss))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [NHỜ CHỈNH SỬA LISP ] Về Lisp chọn nhanh đối tượng Block. Xem đúng bài viết #437552 để đọc hướng dẫn và trao đổi thêm.

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