Jump to content

Lisp lệnh VE trong chủ đề “Xin được diễn giải về Lisp chèn ký tự !!!”

Tôi có một đoạn List như sau:

(defun C:ve (/ scalei  pto  mtxtin i orx pti)

 (setq pto (getpoint "Nhap toa do "))
 (setq scalei (getreal "Nhap khoang cach chu: "))
 (setq mtxtin "")
 (setq mtxtin (getstring "input text: "))
 (setq tlen  (strlen mtxtin))
 (setq i 1)
 (setq orx (car pto))
 (while (<= i tlen )

(setq pti (polar pto  0.0 orx)) 


(if (= (substr mtxtin i 1) "a") (command "Insert" "a" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "b")	(command "Insert" "b" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "c")	(command "Insert" "c" pti "" "" ""))
(if (= (substr mtxtin i 1) "d")	(command "Insert" "d" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "e")	(command "Insert" "e" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "f")	(command "Insert" "f" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "g")	(command "Insert" "g" pti "" "" ""))



(if (= (substr mtxtin i 1) "h")	(command "Insert" "h" pti "" "" ""))
(if (= (substr mtxtin i 1) "i")	(command "Insert" "i" pti "" "" "" ))
(if (= (substr mtxtin i 1) "j")	(command "Insert" "j" pti ""  "" ""))
(if (= (substr mtxtin i 1) "k")	(command "Insert" "k" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "l")	(command "Insert" "l" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "m")	(command "Insert" "m" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "n")	(command "Insert" "n" pti ""  "" ""))

   	(if (= (substr mtxtin i 1) "o")	(command "Insert" "o" pti "" "" ""))
(if (= (substr mtxtin i 1) "p")	(command "Insert" "p" pti "" "" "" ))
(if (= (substr mtxtin i 1) "q")	(command "Insert" "q" pti ""  "" ""))
(if (= (substr mtxtin i 1) "r")	(command "Insert" "r" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "s")	(command "Insert" "s" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "t")	(command "Insert" "t" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "u")	(command "Insert" "u" pti ""  "" ""))

   	(if (= (substr mtxtin i 1) "v")	(command "Insert" "v" pti "" "" ""))
(if (= (substr mtxtin i 1) "x")	(command "Insert" "x" pti "" "" "" ))
(if (= (substr mtxtin i 1) "y")	(command "Insert" "y" pti ""  "" ""))
(if (= (substr mtxtin i 1) "z")	(command "Insert" "z" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "w")	(command "Insert" "w" pti ""  "" ""))


   	(setq orx (+ scalei orx))

  	(setq i (1+ i))	
 )	
)

Và đi kèm với nó là File ABC

https://www.cadviet.com/upfiles/ABC.dwg

 

Bác Hoanh và các cao thủ có thể giúp tôi chỉnh sửa nó với... hiện nay tôi muốn sử dụng list mà ko cần đi kèm với File cad có được ko ? và tôi muốn chèn ký tự tại chính điểm chọn thì làm thế nào (hiện tại điểm chèn ký tự ko trùng với điểm chọn)

Xin các bác chỉ giáo dùm... xin cảm ơn... rất nhiều

Cadviet rất hay và ý nghĩa, chúc các bạn mạnh khoẻ...

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 12405_ve.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 VE để chạy lisp.

Mã nguồn 12405_ve.lsp (trích từ bài viết gốc)

(defun C:ve (/ scalei  pto  mtxtin i orx pti)

 (setq pto (getpoint "Nhap toa do "))
 (setq scalei (getreal "Nhap khoang cach chu: "))
 (setq mtxtin "")
 (setq mtxtin (getstring "input text: "))
 (setq tlen  (strlen mtxtin))
 (setq i 1)
 (setq orx (car pto))
 (while (<= i tlen )

(setq pti (polar pto  0.0 orx)) 


(if (= (substr mtxtin i 1) "a") (command "Insert" "a" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "b")	(command "Insert" "b" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "c")	(command "Insert" "c" pti "" "" ""))
(if (= (substr mtxtin i 1) "d")	(command "Insert" "d" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "e")	(command "Insert" "e" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "f")	(command "Insert" "f" pti "" "" ""))
   	(if (= (substr mtxtin i 1) "g")	(command "Insert" "g" pti "" "" ""))



(if (= (substr mtxtin i 1) "h")	(command "Insert" "h" pti "" "" ""))
(if (= (substr mtxtin i 1) "i")	(command "Insert" "i" pti "" "" "" ))
(if (= (substr mtxtin i 1) "j")	(command "Insert" "j" pti ""  "" ""))
(if (= (substr mtxtin i 1) "k")	(command "Insert" "k" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "l")	(command "Insert" "l" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "m")	(command "Insert" "m" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "n")	(command "Insert" "n" pti ""  "" ""))

   	(if (= (substr mtxtin i 1) "o")	(command "Insert" "o" pti "" "" ""))
(if (= (substr mtxtin i 1) "p")	(command "Insert" "p" pti "" "" "" ))
(if (= (substr mtxtin i 1) "q")	(command "Insert" "q" pti ""  "" ""))
(if (= (substr mtxtin i 1) "r")	(command "Insert" "r" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "s")	(command "Insert" "s" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "t")	(command "Insert" "t" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "u")	(command "Insert" "u" pti ""  "" ""))

   	(if (= (substr mtxtin i 1) "v")	(command "Insert" "v" pti "" "" ""))
(if (= (substr mtxtin i 1) "x")	(command "Insert" "x" pti "" "" "" ))
(if (= (substr mtxtin i 1) "y")	(command "Insert" "y" pti ""  "" ""))
(if (= (substr mtxtin i 1) "z")	(command "Insert" "z" pti ""  "" ""))
   	(if (= (substr mtxtin i 1) "w")	(command "Insert" "w" pti ""  "" ""))


   	(setq orx (+ scalei orx))

  	(setq i (1+ i))	
 )	
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Xin được diễn giải về Lisp chèn ký tự !!!. Xem đúng bài viết #12405 để đọc hướng dẫn và trao đổi thêm.

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