Jump to content

Lisp lệnh TDT trong chủ đề “Lỗi khi sử dụng lisp cad tính diện tích”

Các Bạn dùng thử cái này

(defun c:tdt ( / dtl pt ent ss)
  (vl-load-com)
  (or #tl (setq #tl (getreal "\nMau so ti le ban ve: ")))
  (or #htxt (setq #htxt (getreal "\nChieu cao text: ")))
  (or #sole (setq #sole (getint "\nSo le: ")))
  (setq dtl 0)
  (setq ss (ssadd))
  (while (and (setq pt (getpoint "\nPick internal point : "))
	      (vl-cmdf "_.-boundary" pt "")
	      (setq ent (entlast))
	      (vl-cmdf "_.-hatch" "_s" ent "" "_P" "ANSI31" 2 0 "")
	      )
    (setq ss (ssadd ent ss)
	  ss (ssadd (entlast) ss)
	  )
    (setq dtl (+  dtl (vla-get-area (vlax-ename->vla-object ent))))
    )
  (and (/= dtl 0)
       (setq pt (getpoint "\nPoint to write: "))
       (entmake	(list
		  (cons 0 "TEXT")
;;;		  (cons 8 layer)
		  (cons 1 (rtos (/ dtl #tl #tl) 2 #sole))
;;;		  (cons 7 style)
		  (cons 10 pt)
		  (cons 40 #htxt)
		  )
		)
       (vl-cmdf "_.erase" ss "")
       )
  (princ)
  )

 

Cách dùng

  1. Tải tệp 463700_tdt.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 TDT để chạy lisp.

Mã nguồn 463700_tdt.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/181760-l%E1%BB%97i-khi-s%E1%BB%AD-d%E1%BB%A5ng-lisp-cad-t%C3%ADnh-di%E1%BB%87n-t%C3%ADch/
(defun c:tdt ( / dtl pt ent ss)
  (vl-load-com)
  (or #tl (setq #tl (getreal "\nMau so ti le ban ve: ")))
  (or #htxt (setq #htxt (getreal "\nChieu cao text: ")))
  (or #sole (setq #sole (getint "\nSo le: ")))
  (setq dtl 0)
  (setq ss (ssadd))
  (while (and (setq pt (getpoint "\nPick internal point : "))
	      (vl-cmdf "_.-boundary" pt "")
	      (setq ent (entlast))
	      (vl-cmdf "_.-hatch" "_s" ent "" "_P" "ANSI31" 2 0 "")
	      )
    (setq ss (ssadd ent ss)
	  ss (ssadd (entlast) ss)
	  )
    (setq dtl (+  dtl (vla-get-area (vlax-ename->vla-object ent))))
    )
  (and (/= dtl 0)
       (setq pt (getpoint "\nPoint to write: "))
       (entmake	(list
		  (cons 0 "TEXT")
;;;		  (cons 8 layer)
		  (cons 1 (rtos (/ dtl #tl #tl) 2 #sole))
;;;		  (cons 7 style)
		  (cons 10 pt)
		  (cons 40 #htxt)
		  )
		)
       (vl-cmdf "_.erase" ss "")
       )
  (princ)
  )

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Lỗi khi sử dụng lisp cad tính diện tích. Xem đúng bài viết #463700 để đọc hướng dẫn và trao đổi thêm.

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