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í dụ như giờ e đã có file lisp này trong máy rồi ( file lisp sau khi đã convert file lệnh ấy ). Có cánh nào để mỗi lần sử dụng e chỉ cần dùng lệnh thì lisp sẽ đc load vào hay unload ra mà không phải dùng đến lệnh AP và laod lisp ko?

Cách dùng

  1. Tải tệp 15789_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 15789_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 #15789 để đọc hướng dẫn và trao đổi thêm.

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