Lisp lệnh S2P trong chủ đề “làm sao để chuyển đổi đường Spline thành Pline”
(defun C:s2p () (while (not (and (setq lstSelection (entsel "\nSelect Spline: ")) (setq sngSegment (getdist "\nGet Segment Length: ")) (setq objSelection (vlax-ename->vla-object (car lstSelection))) (wcmatch (vla-get-objectname objSelection) "AcDb2dPolyline,AcDbPolyline,AcDbLine,AcDbArc,AcDbSpline" ) ) ) (princ "\nError please select again: ") ) (setq sngLength (vlax-curve-getDIstAtParam objSelection (vlax-curve-getEndParam objSelection) ) sngDistance 0.0 ) (vl-cmdf "._pline" (vlax-curve-getpointatDist objSelection 0.0)) (repeat (fix (/ sngLength sngSegment)) (vl-cmdf (vlax-curve-getpointatDist objSelection sngDistance)) (setq sngDistance (+ sngDistance sngSegment)) ) (vl-cmdf (vlax-curve-getPointAtParam objSelection (vlax-curve-getEndParam objSelection) ) "" ) )
Đoạn mã trên đây cũng khá hay. bạn thử dùng nhé.
Bro có thể viết lisp sử dụng arc trong polyline được không , mình thấy nhiều đoạn thẳng quá
- Tải lisp
- 61028_s2p.lsp
Cách dùng
- Tải tệp 61028_s2p.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 S2P để chạy lisp.
Mã nguồn 61028_s2p.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/5056-l%C3%A0m-sao-%C4%91%E1%BB%83-chuy%E1%BB%83n-%C4%91%E1%BB%95i-%C4%91%C6%B0%E1%BB%9Dng-spline-th%C3%A0nh-pline/
(defun C:s2p ()
(while (not (and
(setq lstSelection (entsel "\nSelect Spline: "))
(setq sngSegment (getdist "\nGet Segment Length: "))
(setq objSelection (vlax-ename->vla-object (car
lstSelection)))
(wcmatch (vla-get-objectname objSelection)
"AcDb2dPolyline,AcDbPolyline,AcDbLine,AcDbArc,AcDbSpline"
)
)
)
(princ "\nError please select again: ")
)
(setq sngLength (vlax-curve-getDIstAtParam objSelection
(vlax-curve-getEndParam objSelection)
)
sngDistance 0.0
)
(vl-cmdf "._pline" (vlax-curve-getpointatDist objSelection 0.0)) (repeat (fix (/ sngLength sngSegment))
(vl-cmdf (vlax-curve-getpointatDist objSelection sngDistance))
(setq sngDistance (+ sngDistance sngSegment))
)
(vl-cmdf (vlax-curve-getPointAtParam objSelection
(vlax-curve-getEndParam objSelection)
)
""
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề làm sao để chuyển đổi đường Spline thành Pline. Xem đúng bài viết #61028 để đọc hướng dẫn và trao đổi thêm.