Chuy?n ???ng Cong Tròn, Spline Thành Pline G?m Nhi?u ?o?n Th?ng Nh? N?i L?i
Cho b?n 1 cái t?m nè! L?nh: HA
(defun HA:ListPoints1 (ent len / x lenc lst) (setq x 0 lenc (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) lst (cons (vlax-curve-getpointatdist ent x) lst)) (while (< (setq x (+ x len)) lenc) (setq lst (cons (vlax-curve-getpointatdist ent x) lst))) (reverse (setq lst (cons (vlax-curve-getEndpoint ent) lst)))) (defun LWPoly (lst cls) (entmake (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst)))) ;-----(vlax-curve-isclosed ent) (defun C:HA() (setq ent (car (entsel "\nChon Curve de Convert: "))) (setq lst (HA:ListPoints1 ent 100)) (LWPoly lst 0) (princ))
- Tải lisp
- 400545_ha.lsp
Cách dùng
- Tải tệp 400545_ha.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 HA để chạy lisp.
Mã nguồn 400545_ha.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/162769-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-chuy%E1%BB%83n-%C4%91%C6%B0%E1%BB%9Dng-cong-tr%C3%B2n-spline-th%C3%A0nh-pline-g%E1%BB%93m-nhi%E1%BB%81u-%C4%91o%E1%BA%A1n-th%E1%BA%B3ng-nh%E1%BB%8F-n%E1%BB%91i-l%E1%BA%A1i/
(defun HA:ListPoints1 (ent len / x lenc lst)
(setq x 0 lenc (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) lst (cons (vlax-curve-getpointatdist ent x) lst))
(while (< (setq x (+ x len)) lenc)
(setq lst (cons (vlax-curve-getpointatdist ent x) lst)))
(reverse (setq lst (cons (vlax-curve-getEndpoint ent) lst))))
(defun LWPoly (lst cls)
(entmake (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline")
(cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst))))
;-----(vlax-curve-isclosed ent)
(defun C:HA()
(setq ent (car (entsel "\nChon Curve de Convert: ")))
(setq lst (HA:ListPoints1 ent 100))
(LWPoly lst 0)
(princ))Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ Viết Lisp] Chuyển Đường Cong Tròn, Spline Thành Pline Gồm Nhiều Đoạn Thẳng Nhỏ Nối Lại. Xem đúng bài viết #400545 để đọc hướng dẫn và trao đổi thêm.