Jump to content

Lisp lệnh PGP2 trong chủ đề “cánh lưu lại các phím tắt AutoCAD”

bạn dùng lệnh pgp2lsp sau đây để convert file pgp hiện hành của bạn thành 1 file lisp. Sau đó copy file lisp này sang máy khác rồi appload lên rồi dùng.

(defun c:pgp2lsp( / )
 (setq    
   flsp (open (getfiled "PGP to lisp - free lisp from CADViet.com" "cadviet_key" "lsp" 1) "w")
   fpgp (open (findfile "acad.pgp") "r")
 )
 (while (setq curstr (read-line fpgp))
   (if (and (/= (substr curstr 1 1) ";") (setq vt (vl-string-position (ascii ",") curstr)) (> vt 0))
     (progn
(setq lenhtat (vl-string-trim " " (substr curstr 1 vt))
      lenhdu  (vl-string-trim "*" (vl-string-trim " " (substr curstr (+ vt 2))))
      lenhlsp (strcat "(defun c:" lenhtat "()(command \"" lenhdu "\"))")
       )
(if (not (vl-string-position (ascii " ") lenhdu))
(write-line lenhlsp flsp)
  )
     )
   )
 )
 (close flsp)
 (close fpgp)
 (princ)
)

Vậy bây giờ em muốn lưu file fisp này ở 1 thư mục cố định và 1 tên cố định thì làm thế nào vậy anh ?

Cách dùng

  1. Tải tệp 16346_pgp2.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 PGP2 để chạy lisp.

Mã nguồn 16346_pgp2.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/3351-c%C3%A1nh-l%C6%B0u-l%E1%BA%A1i-c%C3%A1c-ph%C3%ADm-t%E1%BA%AFt-autocad/
(defun c:pgp2lsp( / )
 (setq    
   flsp (open (getfiled "PGP to lisp - free lisp from CADViet.com" "cadviet_key" "lsp" 1) "w")
   fpgp (open (findfile "acad.pgp") "r")
 )
 (while (setq curstr (read-line fpgp))
   (if (and (/= (substr curstr 1 1) ";") (setq vt (vl-string-position (ascii ",") curstr)) (> vt 0))
     (progn
(setq lenhtat (vl-string-trim " " (substr curstr 1 vt))
      lenhdu  (vl-string-trim "*" (vl-string-trim " " (substr curstr (+ vt 2))))
      lenhlsp (strcat "(defun c:" lenhtat "()(command \"" lenhdu "\"))")
       )
(if (not (vl-string-position (ascii " ") lenhdu))
(write-line lenhlsp flsp)
  )
     )
   )
 )
 (close flsp)
 (close fpgp)
 (princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề cánh lưu lại các phím tắt AutoCAD. Xem đúng bài viết #16346 để đọc hướng dẫn và trao đổi thêm.

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