(GÓC NHỜ VẢ) XIN LISP TÍNH ĐỘ DỐC ĐOẠN THẲNG VÀ XÓA NHỮNG ĐOẠN THẲNG CÓ ĐỘ DỐC THEO ĐIỀU KIỆN
Bạn dùng cái này. Lệnh là NHT
(defun c:nht (/ EN L LAY LSP P X Y)
(while (setq en (entsel "\nChon duong pline"))
(setq en (car en))
(setq lay (cdr (assoc 8 (entget en))))
(setq lsp
(mapcar
'cdr
(vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget en))
) ;_ end of mapcar
) ;_ end of setq
(mapcar
'(lambda (x y)
(setq l (mapcar '- x y))
(if (>= (abs (/ (cadr l) (car l))) 0.3);DO DOC LON HON 30%
(entmakex
(append
(list (cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 2)
(cons 8 LAY)
) ;_ end of list
(mapcar (function (lambda (p) (cons 10 p))) (LIST X Y))
) ;_ end of append
) ;_ end of entmakex
) ;_ end of if
) ;_ end of lambda
lsp
(cdr lsp)
) ;_ end of mapcar
(entdel en)
) ;_ end of while
(princ)
) ;_ end of defun
- Tải lisp
- 439150_nht.lsp
Cách dùng
- Tải tệp 439150_nht.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 NHT để chạy lisp.
Mã nguồn 439150_nht.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/177173-%C4%91%C3%A3-xong-xin-lisp-t%C3%ADnh-%C4%91%E1%BB%99-d%E1%BB%91c-%C4%91o%E1%BA%A1n-th%E1%BA%B3ng-v%C3%A0-x%C3%B3a-nh%E1%BB%AFng-%C4%91o%E1%BA%A1n-th%E1%BA%B3ng-c%C3%B3-%C4%91%E1%BB%99-d%E1%BB%91c-theo-%C4%91i%E1%BB%81u-ki%E1%BB%87n/
(defun c:nht (/ EN L LAY LSP P X Y)
(while (setq en (entsel "\nChon duong pline"))
(setq en (car en))
(setq lay (cdr (assoc 8 (entget en))))
(setq lsp
(mapcar
'cdr
(vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget en))
) ;_ end of mapcar
) ;_ end of setq
(mapcar
'(lambda (x y)
(setq l (mapcar '- x y))
(if (>= (abs (/ (cadr l) (car l))) 0.3);DO DOC LON HON 30%
(entmakex
(append
(list (cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 2)
(cons 8 LAY)
) ;_ end of list
(mapcar (function (lambda (p) (cons 10 p))) (LIST X Y))
) ;_ end of append
) ;_ end of entmakex
) ;_ end of if
) ;_ end of lambda
lsp
(cdr lsp)
) ;_ end of mapcar
(entdel en)
) ;_ end of while
(princ)
) ;_ end of defunThảo luận gốc
Lisp được chia sẻ trong chủ đề (Đã xong) XIN LISP TÍNH ĐỘ DỐC ĐOẠN THẲNG VÀ XÓA NHỮNG ĐOẠN THẲNG CÓ ĐỘ DỐC THEO ĐIỀU KIỆN. Xem đúng bài viết #439150 để đọc hướng dẫn và trao đổi thêm.