Jump to content

Lisp lệnh FD trong chủ đề “Xin chỉ giúp tử mm ra meter !”

23 giờ trước, nguyenvinh5779 đã nói:

Xin cám on bạn @huunhantvxdts:

Bạn cho chỉ thêm cho mình : Mình  muốn lấy 2 số thập phân  thì phải chỉnh như thế nào !

Xin cám on ban nhieu .

Gửi bạn

(defun C:fd( / ss L e #h tongcd ent txtObj)
(vl-load-com)
(setq ent (car (entsel "\nChon text lay chieu cao")))
(setq #h (cdr (assoc 40 (entget ent))))
(defun Length1(e) (/ (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) 1000))
(or ans (setq ans 1))
(prompt "\nChon cac duong tính chieu dai")
(setq tongcd (apply '+ (mapcar 'Length1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))))))))
;(getvar "dimlfac")
(setq L (strcat "L : " (vl-princ-to-string (rtos (* (getvar "dimlfac") tongcd) 2 2)) "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))

 

Cách dùng

  1. Tải tệp 463270_fd.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 FD để chạy lisp.

Mã nguồn 463270_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/?tab=comments#comment-463270
(defun C:fd( / ss L e #h tongcd ent txtObj)
(vl-load-com)
(setq ent (car (entsel "\nChon text lay chieu cao")))
(setq #h (cdr (assoc 40 (entget ent))))
(defun Length1(e) (/ (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) 1000))
(or ans (setq ans 1))
(prompt "\nChon cac duong tính chieu dai")
(setq tongcd (apply '+ (mapcar 'Length1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))))))))
;(getvar "dimlfac")
(setq L (strcat "L : " (vl-princ-to-string (rtos (* (getvar "dimlfac") tongcd) 2 2)) "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 #463270 để đọc hướng dẫn và trao đổi thêm.

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