Nh? Các Bác Giúp Em Gi?i Quy?t Bài Toán Này V?i !
Xài t?m cái này. Ch? dùng cho LWPOLYLINE.
(defun c:tes(/ D D1 D2 D3 DN DT E EG EL EL1 EL2 X Y) (defun doimn (v a b) (command "change" v "" "P" "C" a "LT" b "")) (defun laydinhr (e) (mapcar 'cdr (vl-remove-if-not '(lambda(x) (= 10 (car x))) (entget e)))) (defun line (a b m) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b) (cons 62 m)))) (command "ucs" "w") (setq e (car (entsel "\nChon polyline:")) eg (laydinhr e) dt (polar (car eg) (angle (car eg) (nth 2 eg)) (* 0.5 (distance (car eg) (nth 2 eg)) )) dn (polar (car eg) (angle (nth 2 eg) (car eg)) (* 0.5 (distance (car eg) (nth 2 eg)) ))) (setq d (getreal "\nKich thuoc D:")) (command "offset" (abs d) e (if (> d 0) dn dt) "") (setq el (entlast)) (doimn el 6 "continuous") (setq d1 (getreal "\nKich thuoc D1:")) (command "offset" d1 el dn "") (setq el1 (entlast)) (doimn el1 3 "continuous") (setq d2 (getreal "\nKich thuoc D2:")) (command "offset" d2 el dt "") (doimn (entlast) 3 "continuous") (setq d3 (getreal "\nKich thuoc D3:")) (command "offset" (+ d2 d3) el dt "") (setq el2 (entlast)) (doimn el2 3 "continuous") (mapcar '(lambda(x y) (line x y 3)) (laydinhr el1) (laydinhr el2)) (princ) )
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 402875_tes.lsp.
- 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 TES để chạy lisp.
Mã nguồn 402875_tes.lsp (trích từ bài viết gốc)
(defun c:tes(/ D D1 D2 D3 DN DT E EG EL EL1 EL2 X Y)
(defun doimn (v a b) (command "change" v "" "P" "C" a "LT" b ""))
(defun laydinhr (e) (mapcar 'cdr (vl-remove-if-not '(lambda(x) (= 10 (car x))) (entget e))))
(defun line (a b m) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b) (cons 62 m))))
(command "ucs" "w")
(setq e (car (entsel "\nChon polyline:"))
eg (laydinhr e)
dt (polar (car eg) (angle (car eg) (nth 2 eg)) (* 0.5 (distance (car eg) (nth 2 eg)) ))
dn (polar (car eg) (angle (nth 2 eg) (car eg)) (* 0.5 (distance (car eg) (nth 2 eg)) )))
(setq d (getreal "\nKich thuoc D:"))
(command "offset" (abs d) e (if (> d 0) dn dt) "") (setq el (entlast)) (doimn el 6 "continuous")
(setq d1 (getreal "\nKich thuoc D1:"))
(command "offset" d1 el dn "") (setq el1 (entlast)) (doimn el1 3 "continuous")
(setq d2 (getreal "\nKich thuoc D2:"))
(command "offset" d2 el dt "") (doimn (entlast) 3 "continuous")
(setq d3 (getreal "\nKich thuoc D3:"))
(command "offset" (+ d2 d3) el dt "") (setq el2 (entlast)) (doimn el2 3 "continuous")
(mapcar '(lambda(x y) (line x y 3)) (laydinhr el1) (laydinhr el2))
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Nhờ Các Bác Giúp Em Giải Quyết Bài Toán Này Với !. Xem đúng bài viết #402875 để đọc hướng dẫn và trao đổi thêm.