Kết hợp lisp
2 giờ trước, loranypt đã nói:@anhGeodesy gần hoàn hảo, nếu dc 1 số điểm sau cần giải quyết:
1. xóa đường pl sau khi nhập điểm đầu và cuối
2. cho chọn khoảng cách giữa các thanh thép (hiện tại mặc định đang để 200)
3. sau khi đo chiều dài thép xong add thẳng text vào text đầu được ko khỏi cần bước 3.
đã like thanks bác nhiều
;; free lisp from cadviet.com ;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/175622-y%C3%AAu-c%E1%BA%A7u-k%E1%BA%BFt-h%E1%BB%A3p-lisp/ ;; free lisp from cadviet.com ;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/163324-lisp-r%C3%A3i-th%C3%A9p-s%C3%A0n/ (defun c:sl (/ a1 c) (setq luu (getvar "osmode")) (setq lay (getvar "clayer")) (setq p1 (getpoint "Chon diem xuat phat\n")) (setq p2 (getpoint p1 "Chon diem ket thuc\n")) ;(setq line (command "_Pline" p1 p2 "")) ;(setq a1 (Distance p1 p2)) (or (and a (or (= (type a) 'int) (= (type a) 'real))) (setq a 200) (setq a (cond ((getint (strcat "\nNh\U+1EADp @ r\U+1EA3i th\U+00E9p (K/c R\U+1EA3i) <" (rtos a 2 2) ">: ") ) ) (a) ) ) ) (setq Caochu 300) (setq Caochu (cond ((getint (strcat "\nNh\U+1EADp chi\U+1EC1u cao ch\U+1EEF (Text Hight) <" (rtos Caochu 2 2) ">: ") ) ) (Caochu) ) ) (or (and duongkinhthep (or (= (type duongkinhthep) 'int) (= (type duongkinhthep) 'real))) (setq duongkinhthep 10) ) (setq duongkinhthep (cond ((getreal (strcat "\nNh\U+1EADp \U+0111\U+01B0\U+1EDDng k\U+00EDnh th\U+00E9p <" (rtos duongkinhthep 2 2) ">: ") ) ) (duongkinhthep) ) ) (setq c (1+ (/ (Distance p1 p2) a))) ; (defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) (Alert (strcat "Chon PLine thep\n")) (setq L (vl-princ-to-string (* (getvar "dimlfac") (apply '+ (mapcar 'Length1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE"))))))) ))) ) ; (setq p (getpoint "\n Chon diem nhap ket qua" )) (entmake (list (cons 0 "TEXT") (cons 10 (list (car p) (cadr p))) (cons 40 Caochu) (cons 1 (strcat (rtos c 2 0) "D" (rtos duongkinhthep 2 0) " L=" (rtos (atof L) 2 0)) ) ) ) (SETVAR "clayer" lay) (setvar "osmode" luu) (princ) ) (defun LM:SelectIf ( msg pred func keyw / sel ) (setq pred (eval pred)) (while (progn (setvar 'ERRNO 0) (if keyw (apply 'initget keyw)) (setq sel (func msg)) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nB\U+1EA1n ch\U+1ECDn sai r\U+1ED3i _ B\U+1EA5m ch\U+1ECDn \U+0111\U+1ED1i t\U+01B0\U+1EE3ng, Try again.") ) ( (eq 'STR (type sel)) nil ) ( (vl-consp sel) (if (and pred (not (pred sel))) (princ "\n\U+0110\U+1ED1i t\U+01B0\U+1EE3ng ch\U+1ECDn kh\U+00F4ng h\U+1EE3p l\U+1EC7.") ) ) ) ) ) sel )
@loranypt Hi vọng trúng ý bạn. đừng quên cho xin Vote +
- Tải lisp
- 434469_sl.lsp
Cách dùng
- Tải tệp 434469_sl.lsp về máy.
- 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 SL để chạy lisp.
Mã nguồn 434469_sl.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/175622-y%C3%AAu-c%E1%BA%A7u-k%E1%BA%BFt-h%E1%BB%A3p-lisp/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/175622-y%C3%AAu-c%E1%BA%A7u-k%E1%BA%BFt-h%E1%BB%A3p-lisp/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/163324-lisp-r%C3%A3i-th%C3%A9p-s%C3%A0n/
(defun c:sl (/ a1 c)
(setq luu (getvar "osmode"))
(setq lay (getvar "clayer"))
(setq p1 (getpoint "Chon diem xuat phat\n"))
(setq p2 (getpoint p1 "Chon diem ket thuc\n"))
;(setq line (command "_Pline" p1 p2 ""))
;(setq a1 (Distance p1 p2))
(or (and a (or (= (type a) 'int) (= (type a) 'real)))
(setq a 200)
(setq a
(cond
((getint (strcat "\nNh\U+1EADp @ r\U+1EA3i th\U+00E9p (K/c R\U+1EA3i) <" (rtos a 2 2) ">: ")
)
)
(a)
)
)
)
(setq Caochu 300)
(setq Caochu
(cond
((getint (strcat "\nNh\U+1EADp chi\U+1EC1u cao ch\U+1EEF (Text Hight) <" (rtos Caochu 2 2) ">: ")
)
)
(Caochu)
)
)
(or (and duongkinhthep (or (= (type duongkinhthep) 'int) (= (type duongkinhthep) 'real)))
(setq duongkinhthep 10)
)
(setq duongkinhthep
(cond
((getreal (strcat "\nNh\U+1EADp \U+0111\U+01B0\U+1EDDng k\U+00EDnh th\U+00E9p <" (rtos duongkinhthep 2 2) ">: ")
)
)
(duongkinhthep)
)
)
(setq c (1+ (/ (Distance p1 p2) a)))
;
(defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)))
(Alert (strcat "Chon PLine thep\n"))
(setq L
(vl-princ-to-string (* (getvar "dimlfac") (apply '+
(mapcar 'Length1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))))))
)))
)
;
(setq p (getpoint "\n Chon diem nhap ket qua" ))
(entmake
(list
(cons 0 "TEXT")
(cons 10 (list (car p) (cadr p)))
(cons 40 Caochu)
(cons
1
(strcat (rtos c 2 0) "D" (rtos duongkinhthep 2 0) " L=" (rtos (atof L) 2 0))
)
)
)
(SETVAR "clayer" lay)
(setvar "osmode" luu)
(princ)
)
(defun LM:SelectIf ( msg pred func keyw / sel ) (setq pred (eval pred))
(while
(progn (setvar 'ERRNO 0) (if keyw (apply 'initget keyw)) (setq sel (func msg))
(cond
( (= 7 (getvar 'ERRNO))
(princ "\nB\U+1EA1n ch\U+1ECDn sai r\U+1ED3i _ B\U+1EA5m ch\U+1ECDn \U+0111\U+1ED1i t\U+01B0\U+1EE3ng, Try again.")
)
( (eq 'STR (type sel))
nil
)
( (vl-consp sel)
(if (and pred (not (pred sel)))
(princ "\n\U+0110\U+1ED1i t\U+01B0\U+1EE3ng ch\U+1ECDn kh\U+00F4ng h\U+1EE3p l\U+1EC7.")
)
)
)
)
)
sel
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu Cầu] Kết hợp lisp. Xem đúng bài viết #434469 để đọc hướng dẫn và trao đổi thêm.