Xuất điểm theo Block thuộc tính qui định bởi tên
Thêm code để phá block attribute sau khi insert vào bản vẽ.
;========LISP DUA DIEM KHONG CHE + DIEM CHI TIET LEN BAN VE=========
;=======================KANGKUNG 03/04/2013=========================
;============07/05/2013 UPDATE: PHA BLOCK SAU KHI INSERT============
(defun C:KK(/ os txt lst Code)
(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"))
)
(sssetfirst nil (ssadd (entlast))) (c:Burst)
)
)
)
)
)
(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)))
(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 234147_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 234147_kk.lsp (trích từ bài viết gốc)
;========LISP DUA DIEM KHONG CHE + DIEM CHI TIET LEN BAN VE=========
;=======================KANGKUNG 03/04/2013=========================
;============07/05/2013 UPDATE: PHA BLOCK SAU KHI INSERT============
(defun C:KK(/ os txt lst Code)
(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"))
)
(sssetfirst nil (ssadd (entlast))) (c:Burst)
)
)
)
)
)
(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)))
(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 #234147 để đọc hướng dẫn và trao đổi thêm.