Jump to content

Lisp lệnh TEST trong chủ đề “Nhờ viết lisp thay đổi thay đổi tỷ lệ Annotation scale”

6 giờ trước, jangboko đã nói:

không đúng bạn ạ. Mình muốn sau khi gõ lệnh thì chọn vào đối tượng chứa anotative ( text, hacth,  dim, block...) thì annotation scale ( vị trí mình khoanh đỏ trên file đính kèm ) thay đổi theo annotion của đối tượng được chọn

1.png

Bạn thử cái này xem:

(defun c:test  (/ dict entsc)
  (if (and
        (setq dict (cdr (assoc 360 (entget (car (entsel "\nChon doi tuong anno: "))))))
        (setq dict (dictsearch dict "AcDbContextDataManager"))
        (setq dict (dictsearch (cdr (assoc -1 dict)) "ACDB_ANNOTATIONSCALES"))
        )
    (foreach n dict
      (if (and
            (= (car n) 350)
            (setq entsc
                   (cdr (assoc 300 (entget (cdr (assoc 340 (entget (cdr n)))))))
                  )
            );and
        (setvar "CANNOSCALE" entsc)
        )
      );foreach
    ) ;if
  (princ)
  )

 

Cách dùng

  1. Tải tệp 440724_test.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 TEST để chạy lisp.

Mã nguồn 440724_test.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/177899-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-thay-%C4%91%E1%BB%95i-thay-%C4%91%E1%BB%95i-t%E1%BB%B7-l%E1%BB%87-annotation-scale/?tab=comments#comment-440688
(defun c:test  (/ dict entsc)
  (if (and
        (setq dict (cdr (assoc 360 (entget (car (entsel "\nChon doi tuong anno: "))))))
        (setq dict (dictsearch dict "AcDbContextDataManager"))
        (setq dict (dictsearch (cdr (assoc -1 dict)) "ACDB_ANNOTATIONSCALES"))
        )
    (foreach n dict
      (if (and
            (= (car n) 350)
            (setq entsc
                   (cdr (assoc 300 (entget (cdr (assoc 340 (entget (cdr n)))))))
                  )
            );and
        (setvar "CANNOSCALE" entsc)
        )
      );foreach
    ) ;if
  (princ)
  )

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Nhờ viết lisp thay đổi thay đổi tỷ lệ Annotation scale. Xem đúng bài viết #440724 để đọc hướng dẫn và trao đổi thêm.

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