Làm sao để thay thế (đối tượng bằng wipeout) ?
Hề hề hề,
Đúng như bạn Chiron đã nói, mình có thể xử lý việc này bằng lisp được, nhưng trước hết bạn hãy mở topic này bên lisp box đã nhé. Như vậy đúng với quy định của diễn đàn và sẽ thuận lợi hơn cho những người khác theo dõi và quan tâm tới vấn đề này. Hãy chịu khó một chút vì quyền lợi chung của mọi người tham gia diễn đàn bạn nhé. Có thể khi bạn post xong topic thì đã có bài trả lời rồi đó.
Hề hề hề,
Đất chả chịu giời thì giời chịu đất vậy. Mình giúp bạn lần này chuyển bài viết về box mới và sửa tiêu đề topic cho đúng với quy định của diễn đàn, mong rằng lần sau bạn sẽ tự thực hiện đúng với quy định nhé.
Hãy dùng thử cái lisp này xem có đúng cái bạn cần không nhé. Lưu ý rằng các vòng tròn của bạn sau khi dùng lisp này sẽ không còn là circle nữa mà là các wipeout tương tự như cái mẫu trong bản vẽ của bạn post. Vì thế chớ có ngạc nhiên khi thấy nó không được tròn vành vạnh nhé.
Trong lisp này mình có nhón một khúc lisp của bác SSG về để xào nấu lại. Vì thế hãy cám ơn bác ấy nhé. Không có bác ấy thì cái lisp này sẽ chả dùng được đâu.
Hề hề hề
(defun c:ch2w (/ ent pt la oldlay oldos d0 d1 ent1 ent2 plst ss1 sscl) (vl-load-com) (command "undo" "be") (setq ent (car (entsel "\n Hay chon mot hinh tron mau muon thay the de tao wipeout ")) pt (cdr (assoc 10 (setq els (entget ent)))) la (cdr (assoc 8 els)) ) (setq oldlay (getvar "clayer")) (setvar "clayer" la) (setq oldos (getvar "osmode")) (setvar "osmode" 0) (if (not d0) (setq d0 0.5));;;Init dividual distance, global variable (setq d1 (getreal (strcat "\nLength of 1 segment <" (rtos d0) ">:")));;;Input distance (if d1 (setq d0 d1) (setq d1 d0));;;Reset or get distance (makepl ent d1) (setq ent1 (entlast)) (command "wipeout" "p" ent1 "n") (setq ent2 (entlast) plst (acet-geom-vertex-list ent1) ss1 (ssget "cp" plst (list (cons 0 "line") (cons 8 "Duong"))) ) (command "draworder" ent2 "" "b") (command "draworder" ss1 "" "b") (command "erase" ent "") (alert "\n Chon tat ca cac vong tron can thay the") (setq sscl (acet-ss-to-list (ssget (list (cons 0 "circle") (cons 8 la))))) (foreach crl sscl (setq p1 (cdr (assoc 10 (entget crl)))) (command "move" ent1 "" pt p1) (command "copy" ent2 "" pt p1) (setq ent2 (entlast) plst (acet-geom-vertex-list ent1) ss1 (ssget "cp" plst (list (cons 0 "line") (cons 8 "Duong"))) ) (command "draworder" ent2 "" "b") (command "draworder" ss1 "" "b") (command "erase" crl "") (setq pt p1 p1 nil) ) (command "erase" ent1 "") (setvar "clayer" oldlay) (setvar "osmode" oldos) (command "undo" "e") (princ) ) ;;;------------------------------------------------------------- (defun makepl ( e d1 / ps pe d d2 p2);;;Make pline along curve e. Length of 1 segment = d1 (vl-load-com);;;Load Visual LISP extensions before use vlax-xxxx functions (setq ps (vlax-curve-getStartPoint e);;;Start point pe (vlax-curve-getEndPoint e);;;End point d (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e));;;Length of curve e d2 d1;;;Init variable distance ) (command "pline");;;Call pline command (command ps);;;Start point (while (<= d2 d);;;While not over end point pe (setq p2 (vlax-curve-getPointAtDist e d2));;;Variable point at d2 = length along curve (command p2);;;Continue pline command from current point to p2 (setq d2 (+ d2 d1));;;Increase distance d2 by d1 );;;End while (if (not (equal pe ps 0.01)) (command pe "");;;Pline to pe and finish command (command "c" ) ) ) ;;;-------------------------------------------------------------Hề hề hề,
Chúc bạn vui
Thành thật em cảm ơn anh rất nhiều, sáng mai đi làm em sẽ làm ngay theo cách anh mách. Lý do em em post ở đây là vì: em nghĩ rằng vấn đề này có thể Copy rồi Dán hoặc Lọc theo kiểu gì đó---->liên quan tới Kỹ thuật Autocad; nên em viết bài này ở đây. Rất mong mọi người bỏ quá cho em. Cảm ơn anh và các bạn đã quan tâm rất nhiều. Chúc mọi người có sức khỏe!
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 185488_ch2w.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 CH2W để chạy lisp.
Mã nguồn 185488_ch2w.lsp (trích từ bài viết gốc)
(defun c:ch2w (/ ent pt la oldlay oldos d0 d1 ent1 ent2 plst ss1 sscl)
(vl-load-com)
(command "undo" "be")
(setq ent (car (entsel "\n Hay chon mot hinh tron mau muon thay the de tao wipeout "))
pt (cdr (assoc 10 (setq els (entget ent))))
la (cdr (assoc 8 els))
)
(setq oldlay (getvar "clayer"))
(setvar "clayer" la)
(setq oldos (getvar "osmode"))
(setvar "osmode" 0)
(if (not d0) (setq d0 0.5));;;Init dividual distance, global variable
(setq d1 (getreal (strcat "\nLength of 1 segment <" (rtos d0) ">:")));;;Input distance
(if d1 (setq d0 d1) (setq d1 d0));;;Reset or get distance
(makepl ent d1)
(setq ent1 (entlast))
(command "wipeout" "p" ent1 "n")
(setq ent2 (entlast)
plst (acet-geom-vertex-list ent1)
ss1 (ssget "cp" plst (list (cons 0 "line") (cons 8 "Duong"))) )
(command "draworder" ent2 "" "b")
(command "draworder" ss1 "" "b")
(command "erase" ent "")
(alert "\n Chon tat ca cac vong tron can thay the")
(setq sscl (acet-ss-to-list (ssget (list (cons 0 "circle") (cons 8 la)))))
(foreach crl sscl
(setq p1 (cdr (assoc 10 (entget crl))))
(command "move" ent1 "" pt p1)
(command "copy" ent2 "" pt p1)
(setq ent2 (entlast)
plst (acet-geom-vertex-list ent1)
ss1 (ssget "cp" plst (list (cons 0 "line") (cons 8 "Duong"))) )
(command "draworder" ent2 "" "b")
(command "draworder" ss1 "" "b")
(command "erase" crl "")
(setq pt p1 p1 nil)
)
(command "erase" ent1 "")
(setvar "clayer" oldlay)
(setvar "osmode" oldos)
(command "undo" "e")
(princ)
)
;;;-------------------------------------------------------------
(defun makepl ( e d1 / ps pe d d2 p2);;;Make pline along curve e. Length of 1 segment = d1
(vl-load-com);;;Load Visual LISP extensions before use vlax-xxxx functions
(setq
ps (vlax-curve-getStartPoint e);;;Start point
pe (vlax-curve-getEndPoint e);;;End point
d (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e));;;Length of curve e
d2 d1;;;Init variable distance
)
(command "pline");;;Call pline command
(command ps);;;Start point
(while (<= d2 d);;;While not over end point pe
(setq p2 (vlax-curve-getPointAtDist e d2));;;Variable point at d2 = length along curve
(command p2);;;Continue pline command from current point to p2
(setq d2 (+ d2 d1));;;Increase distance d2 by d1
);;;End while
(if (not (equal pe ps 0.01))
(command pe "");;;Pline to pe and finish command
(command "c" )
)
)
;;;-------------------------------------------------------------Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Hỏi] Làm sao để thay thế (đối tượng bằng wipeout) ?. Xem đúng bài viết #185488 để đọc hướng dẫn và trao đổi thêm.