Lisp lệnh PLLEV PL2LEV trong chủ đề “GHI CAO ĐỘ TUYẾN CỐNG”
Bạn thử cái này xem nhé
- Tải lisp
- 104766_pllev_pl2lev.lsp
Cách dùng
- Tải tệp 104766_pllev_pl2lev.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 PLLEV PL2LEV để chạy lisp.
Mã nguồn 104766_pllev_pl2lev.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/23285-ghi-cao-%C4%91%E1%BB%99-tuy%E1%BA%BFn-c%E1%BB%91ng/
(defun c:PLLEV(/ PL LenPL I Points LenPoint)
(setq PL (entget (car (entsel "\nChon 1 Polyline: ")))
I 0
LenPL (length PL))
(if (= (cdr (assoc 0 PL)) "LWPOLYLINE")
(progn
(while (< I LenPL)
(if (= (nth 0 (nth I PL)) 10 )
(setq Points (append Points (list (cdr (nth I PL))))
LenPoints (length Points))
)
(setq I (1+ I))
)
(setq LV (getreal "\nNhap cao do dau: ")
Id (Getreal "\nNhap do doc doc: ")
I 0)
(while (< I LenPoints)
(setq Point (nth I Points))
(If (= I 0)
(progn
(command "TEXT" "j" "MC" Point "" "" (rtos LV 2 3) "")
(setq LPoint Point)
)
(progn
(setq Len (distance Lpoint Point)
NewLV (+ LV (/ (* Id Len) 100.0)))
(command "TEXT" "j" "MC" Point "" "" (rtos NewLV 2 3) "")
(setq LPoint Point
LV NewLV)
)
)
(setq I (1+ I))
)
)
)
)
(defun c:PL2LEV(/ PL LenPL I Points LenPoint)
(setq PL (entget (car (entsel "\nChon 1 Polyline: ")))
I 0
LenPL (length PL))
(if (= (cdr (assoc 0 PL)) "LWPOLYLINE")
(progn
(while (< I LenPL)
(if (= (nth 0 (nth I PL)) 10 )
(setq Points (append Points (list (cdr (nth I PL))))
LenPoints (length Points))
)
(setq I (1+ I))
)
(setq SLV (getreal "\nNhap cao do dau: ")
ELV (Getreal "\nNhap cao do cuoi: ")
I 1
Dist 0)
(setq SPoint (nth 0 Points))
(while (< I LenPoints)
(setq Point (nth I Points)
Dist (+ Dist (distance Point Spoint))
Spoint Point
I (1+ I))
)
(setq Id (/ (- ELV SLV) Dist)
I 0)
(while (< I LenPoints)
(setq Point (nth I Points))
(If (= I 0)
(progn
(command "TEXT" "j" "MC" Point "" "" (rtos SLV 2 3) "")
(setq LPoint Point)
)
(progn
(setq Len (distance Lpoint Point)
NewLV (+ SLV (* Id Len)))
(command "TEXT" "j" "MC" Point "" "" (rtos NewLV 2 3) "")
(setq LPoint Point
SLV NewLV)
)
)
(setq I (1+ I))
)
)
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề GHI CAO ĐỘ TUYẾN CỐNG. Xem đúng bài viết #104766 để đọc hướng dẫn và trao đổi thêm.