Jump to content

Nhờ viết lisp phát hiện kích thước đã bị thay đổi

Lisp thay đổi Dim Overrive theo kiểu Find and Replace "gần giống" trong Word đây.

(defun C:HA( / VPCords pllur lst key)
 (defun VPCords()
  ((lambda (offset) ((lambda (viewctr) (list (mapcar '- viewctr offset) (mapcar '+ viewctr offset))) (getvar "viewctr")))
   ((lambda (halfHeight aspectRatio) (list (* halfHeight aspectRatio) halfHeight))
    (* 0.5 (getvar "viewsize"))
    (apply '/ (getvar "screensize")))))
 (setq pllur (vpcords))
 (command "undo" "be")
 (princ "\nChon cac DIM da bi Override de Convert...")
 (if (setq ss (ssget '((0 . "DIMENSION") (1 . "~"))))
  (progn
   (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
   (initget "All  Individually")
   (setq key (getkword "\nSelect type <All>: "))
   (if (not key) (setq key "All"))
   (cond
    ((= key "All")
     (foreach ent lst
      (entmod (subst (cons 1 "") (assoc 1 (entget ent)) (entget ent)))))
    ((= key "Individually")
     (foreach ent lst
      (command "zoom" "c" "non" (cdr (assoc 11 (entget ent))) 5)
   (command "ddedit" ent pause))))))
 (command "zoom" "w" "non" (car pllur) "non" (cadr pllur))
 (command "undo" "e")
 (princ))
 

Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.

Cách dùng

  1. Chép mã nguồn, lưu thành tệp 277499_ha.lsp.
  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 HA để chạy lisp.

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Yêu cầu] Nhờ viết lisp phát hiện kích thước đã bị thay đổi. Xem đúng bài viết #277499 để đọc hướng dẫn và trao đổi thêm.

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