Jump to content

Lisp lệnh ADDDOT trong chủ đề “Thêm dấu chấm"." sau toạ độ X,Y”

Thêm dấu chấm "." sau toạ độ X,Y :

(defun c:AddDot(/ fname fname ifile ofile)
  ; By Gia Bach
  (if (and (setq fname (getfiled "Select Input File" (getvar "dwgprefix") "txt" 8))
	   (setq fname (findfile fname))
	   (setq name (getfiled "Select Output File" (getvar "dwgprefix") ";txt" 9)))
    (progn      
      (setq ifile (open fname "r"))
      (setq ofile (open name "w"))
      (if (and (/= ifile nil)(/= ofile nil))
	(progn
	  (while (setq line (read-line ifile))
	    (setq pos (vl-string-search " Y" line)
		  str (strcat (substr line 1 pos) "." (substr line (+ 1 pos) ) "."))
	    (write-line (strcat str) ofile))
	(close ifile)
	(close ofile) )	)  )  )  
  (princ)  )

 

Cách dùng

  1. Tải tệp 464049_adddot.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 ADDDOT để chạy lisp.

Mã nguồn 464049_adddot.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/192311-th%C3%AAm-d%E1%BA%A5u-ch%E1%BA%A5m-sau-to%E1%BA%A1-%C4%91%E1%BB%99-xy/
(defun c:AddDot(/ fname fname ifile ofile)
  ; By Gia Bach
  (if (and (setq fname (getfiled "Select Input File" (getvar "dwgprefix") "txt" 8))
	   (setq fname (findfile fname))
	   (setq name (getfiled "Select Output File" (getvar "dwgprefix") ";txt" 9)))
    (progn      
      (setq ifile (open fname "r"))
      (setq ofile (open name "w"))
      (if (and (/= ifile nil)(/= ofile nil))
	(progn
	  (while (setq line (read-line ifile))
	    (setq pos (vl-string-search " Y" line)
		  str (strcat (substr line 1 pos) "." (substr line (+ 1 pos) ) "."))
	    (write-line (strcat str) ofile))
	(close ifile)
	(close ofile) )	)  )  )  
  (princ)  )

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Thêm dấu chấm"." sau toạ độ X,Y. Xem đúng bài viết #464049 để đọc hướng dẫn và trao đổi thêm.

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