Xuất điểm theo Block thuộc tính qui định bởi tên
Các anh cho em hỏi tý. Nếu muốn phá khối vừa chèn thì phải sửa code này như nào?
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/69905-yeu-cau-xuat-diem-theo-block-thuoc-tinh-qui-dinh-boi-ten/
;========LISP DUA DIEM KHONG CHE + DIEM CHI TIET LEN BAN VE=========
;=======================KANGKUNG 03/04/2013=========================
(defun C:KK()
(command "UNDO" "BE")
(setq os(getvar "OSMODE"))
(setvar "OSMODE" 0)
(if (not Path) (setq Path(getvar "dwgprefix")))
(setq file(getfiled "Select File:" Path "txt" 2) Path file file_in(open file "R"))
(while(setq txt(read-line file_in))
(if (/= txt nil)
(progn
(setq lst (read (strcat "(" txt ")" )))
(if (= (read txt) (atof (vl-princ-to-string(read txt))))
(command "INSERT" "Point" (list (nth 2 lst) (nth 1 lst) (nth 3 lst)) "1" "1" "0" (rtos (nth 0 lst) 2 0) (rtos (nth 3 lst) 2 2) (vl-princ-to-string(nth 4 lst)))
(progn
(setq Code(substr txt 1 (- (vl-string-search (rtos (fix (nth (- (length lst) 3) lst)) 2 0) txt) 1)))
(cond ((= (strcase(substr Code 1 2)) "TM") (in "TM"))
((= (strcase(substr Code 1 3)) "GPS") (in "GPS"))
((= (strcase(substr Code 1 3)) "DCI") (in "DCI"))
((= (strcase(substr Code 1 4)) "DCII") (in "DCII"))
)
)
)
)
)
)
(close file_in)
(setvar "OSMODE" os)
(command "ZOOM" "E")
(command "UNDO" "END")
(Alert "Well Done")
)
(defun in(ten)
(command "INSERT" ten (list (nth (- (length lst) 2) lst) (nth (- (length lst) 3) lst) (nth (- (length lst) 1) lst)) "1" "1" "0" Code (rtos (nth (- (length lst) 1) lst) 2 3))
(c:burst) (entlast)
)
(princ "\n Written By KangKung - 03/04/2013\n")
(princ "\n Nhap KK de chay chuong trinh\n")
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
- Chép mã nguồn, lưu thành tệp 234113_kk.lsp.
- 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ẽ.
- Gõ lệnh KK để chạy lisp.
Mã nguồn 234113_kk.lsp (trích từ bài viết gốc)
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/69905-yeu-cau-xuat-diem-theo-block-thuoc-tinh-qui-dinh-boi-ten/
;========LISP DUA DIEM KHONG CHE + DIEM CHI TIET LEN BAN VE=========
;=======================KANGKUNG 03/04/2013=========================
(defun C:KK()
(command "UNDO" "BE")
(setq os(getvar "OSMODE"))
(setvar "OSMODE" 0)
(if (not Path) (setq Path(getvar "dwgprefix")))
(setq file(getfiled "Select File:" Path "txt" 2) Path file file_in(open file "R"))
(while(setq txt(read-line file_in))
(if (/= txt nil)
(progn
(setq lst (read (strcat "(" txt ")" )))
(if (= (read txt) (atof (vl-princ-to-string(read txt))))
(command "INSERT" "Point" (list (nth 2 lst) (nth 1 lst) (nth 3 lst)) "1" "1" "0" (rtos (nth 0 lst) 2 0) (rtos (nth 3 lst) 2 2) (vl-princ-to-string(nth 4 lst)))
(progn
(setq Code(substr txt 1 (- (vl-string-search (rtos (fix (nth (- (length lst) 3) lst)) 2 0) txt) 1)))
(cond ((= (strcase(substr Code 1 2)) "TM") (in "TM"))
((= (strcase(substr Code 1 3)) "GPS") (in "GPS"))
((= (strcase(substr Code 1 3)) "DCI") (in "DCI"))
((= (strcase(substr Code 1 4)) "DCII") (in "DCII"))
)
)
)
)
)
)
(close file_in)
(setvar "OSMODE" os)
(command "ZOOM" "E")
(command "UNDO" "END")
(Alert "Well Done")
)
(defun in(ten)
(command "INSERT" ten (list (nth (- (length lst) 2) lst) (nth (- (length lst) 3) lst) (nth (- (length lst) 1) lst)) "1" "1" "0" Code (rtos (nth (- (length lst) 1) lst) 2 3))
(c:burst) (entlast)
)
(princ "\n Written By KangKung - 03/04/2013\n")
(princ "\n Nhap KK de chay chuong trinh\n")Thảo luận gốc
Lisp được chia sẻ trong chủ đề [ Yêu cầu ] Xuất điểm theo Block thuộc tính qui định bởi tên. Xem đúng bài viết #234113 để đọc hướng dẫn và trao đổi thêm.