Jump to content

Lisp lệnh DTL VPL D1 trong chủ đề “Xin Lisp vẽ độ dốc dọc”

Bạn xài cái của mình xem sao
Mình để thêm trường hợp bạn vẽ dôc trên trắc dọc tức là tỷ lệ X và Y có thể không bằng nhau
Dùng LISP bằng lệnh DTL - VPL - D1 (khuyến mãi để đo dốc dọc :D)


;;; Free lisp code from CADViet.com - edit by Mathan
;;; Ve Pline theo chieu dai va do doc
;;;ho tro ve duong do trong civil - nova
(prompt "Edited by Mathan,dat ty le lenh DTL - Ve pline VPL - kiem tra doc lend D1")
;;;;;;;;;;
(defun c:DTL (/ )
(if (= ngang Nil)
(setq ngang 1000)
)
(if (= dung Nil)
(setq dung 100)
)
(setq str (strcat "\nNhap ty le ngang (press Enter or Space for get default): "))
(setq n (getint str))
(if (/= n Nil)
(setq ngang n)
)
(setq str (strcat "\nNhap ty le dung (press Enter or Space for get default): "))
(setq n (getint str))
(if (/= n Nil)
(setq dung n)
)
(setq tyle (/ ngang dung))
)
;;;;;;;;;;;;;;;;;;;;;;
(defun c:vpl (/ Pt Leng Slope X Y alpha)
(setq Pt (getpoint "\nSpecify first point: "))
(while (/= Leng 0.0)
(setq Leng 0.0 )
(vl-cmdf "_.pline" Pt)
(setq Leng (getdist "\nSpecify length of line : "))
(if (/= Leng nil)
(progn
(setq Slope (getreal "\nSpecify slope of line ...%: ")
alpha (atan Slope)
X leng
Y (/ (* Leng slope tyle) 100)
);
(setq Pt (list (+ X (car Pt)) (+ Y (cadr Pt))))
);
(progn
(vl-cmdf "")
(exit)
);
);end if
);end while
(princ)
);end defun
;;; ******************************** DO do doc don gian (d1) ***************************
(defun c:d1 ()
(setq p1 (getpoint "\nchon diem thu nhat: ")
p2 (getpoint p1"\nChon diem thu hai: "))
(setq dx (abs(- (car p1)(car p2))))
;---------------------------------;
(setq dx1 (abs(- (car p1)(car p2))))
(setq dy1 (abs(- (cadr p1)(cadr p2))))
(setq tl1 (/ (* dy1 100) (* dx tyle)))
(princ (strcat "\nDo doc hien tai(theo ty le): " (rtos tl1 2 4) "%"))
(princ)
)

Cách dùng

  1. Tải tệp 206747_dtl_vpl_d1.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 DTL VPL D1 để chạy lisp.

Mã nguồn 206747_dtl_vpl_d1.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/14999-xin-lisp-v%E1%BA%BD-%C4%91%E1%BB%99-d%E1%BB%91c-d%E1%BB%8Dc/
;;; Free lisp code from CADViet.com - edit by Mathan
;;; Ve Pline theo chieu dai va do doc
;;;ho tro ve duong do trong civil - nova
(prompt "Edited by Mathan,dat ty le lenh DTL - Ve pline VPL - kiem tra doc lend D1")
;;;;;;;;;;
(defun c:DTL (/ )
(if (= ngang Nil)
(setq ngang 1000)   
 )
(if (= dung Nil)
(setq dung 100)   
 )
(setq str (strcat "\nNhap ty le ngang [" (itoa ngang) "] (press Enter or Space for get default): "))
 (setq n (getint str))
 (if (/= n Nil)
(setq ngang n)   
 )
(setq str (strcat "\nNhap ty le dung [" (itoa dung) "] (press Enter or Space for get default): "))
 (setq n (getint str))
 (if (/= n Nil)
(setq dung n)   
 )
(setq tyle (/ ngang dung))
)
;;;;;;;;;;;;;;;;;;;;;;
(defun c:vpl (/ Pt Leng Slope X Y alpha)
 (setq Pt (getpoint "\nSpecify first point: "))
 (while (/= Leng 0.0)
(setq Leng 0.0 )
(vl-cmdf "_.pline" Pt)
(setq Leng (getdist "\nSpecify length of line : "))
(if (/= Leng nil)
 	(progn
(setq Slope (getreal "\nSpecify slope of line ...%: ")
  	alpha (atan Slope)
  	X leng
  	Y (/ (* Leng slope tyle) 100)
  	);
(setq Pt (list (+ X (car Pt)) (+ Y (cadr Pt))))
);
 	(progn
(vl-cmdf "")
(exit)
);
 	);end if
);end while
 (princ)
 );end defun
;;; ******************************** DO do doc don gian (d1) ***************************
(defun  c:d1 ()
(setq p1 (getpoint "\nchon diem thu nhat: ")
 	p2 (getpoint p1"\nChon diem thu hai: "))
(setq dx (abs(- (car p1)(car p2))))
;---------------------------------;
(setq dx1 (abs(- (car p1)(car p2))))
(setq dy1 (abs(- (cadr p1)(cadr p2))))
(setq tl1 (/ (* dy1 100) (* dx tyle)))
(princ (strcat "\nDo doc hien tai(theo ty le): " (rtos tl1 2 4) "%"))
(princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Xin Lisp vẽ độ dốc dọc. Xem đúng bài viết #206747 để đọc hướng dẫn và trao đổi thêm.

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