Lisp lệnh FD trong chủ đề “Xin chỉ giúp tử mm ra meter !”
Lỗi là do lisp bạn copy sai (thiếu con số 0). Sửa giùm bạn
(defun C:fd( / ss L e #h) (vl-load-com) (defun Length1(e) (/ (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) 1000)) (or ans (setq ans 1)) (setq #h 200 L (strcat "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")))))))))) "m")) (setq ans (cond ((getint (strcat "\nPhuong an nhap ket qua < " (itoa ans) " > :")))(ans)) txtObj (cond ((= ans 1) (vlax-ename->vla-object (car (entsel "\nChon text ghi ket qua :")))) (T (vla-addtext (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) L (vlax-3d-point (getpoint "\n Chon diem nhap ket qua" )) #h )))) (vla-put-TextString txtObj L) (vla-put-Height txtObj #h) (princ))
- Tải lisp
- 463149_fd.lsp
Cách dùng
- Tải tệp 463149_fd.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 FD để chạy lisp.
Mã nguồn 463149_fd.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/191769-xin-ch%E1%BB%89-gi%C3%BAp-t%E1%BB%AD-mm-ra-meter/
(defun C:fd( / ss L e #h)
(vl-load-com)
(defun Length1(e) (/ (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) 1000))
(or ans (setq ans 1))
(setq
#h 200
L (strcat "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")))))))))) "m"))
(setq
ans (cond ((getint (strcat "\nPhuong an nhap ket qua < " (itoa ans) " > :")))(ans))
txtObj (cond ((= ans 1) (vlax-ename->vla-object (car (entsel "\nChon text ghi ket qua :"))))
(T (vla-addtext (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) L (vlax-3d-point (getpoint "\n Chon diem nhap ket qua" )) #h ))))
(vla-put-TextString txtObj L)
(vla-put-Height txtObj #h)
(princ))
Thảo luận gốc
Lisp được chia sẻ trong chủ đề Xin chỉ giúp tử mm ra meter !. Xem đúng bài viết #463149 để đọc hướng dẫn và trao đổi thêm.