Lisp lệnh DB trong chủ đề “Đổi điểm chèn sau khi đã chèn block khắp nơi”
Ý 1 : Code của Tue_NV không bị lỗi này.
Ý 2 : Tue_NV đã chỉnh lại theo ý của bạn xuantran
Các bạn thử test lại xem. Có vấn đề gì thì Tue_NV sẽ hoàn thiện code này :
- Tải lisp
- 62844_db.lsp
Cách dùng
- Tải tệp 62844_db.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 DB để chạy lisp.
Mã nguồn 62844_db.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/11276-%C4%91%E1%BB%95i-%C4%91i%E1%BB%83m-ch%C3%A8n-sau-khi-%C4%91%C3%A3-ch%C3%A8n-block-kh%E1%BA%AFp-n%C6%A1i/
(defun c:DB(/ n i tenmoi snn mau tencu diemcu diemmoi Trx Try Trz ss sn ent
TLXc TLYc TLZc gocquayc TLX TLY TLZ tam gocquay pointX pointY pointZ pointmoi lay)
(command "undo" "be")
(setq lay (getvar "clayer"))
(setq snn (car(entsel "\n Chon Block can doi diem chen :")))
(setq tenmoi (getstring "\n Nhap ten block moi :"))
(while (tblsearch "block" tenmoi)
(princ "\n Ten Block da co :")
(setq tenmoi (getstring "\n Nhap lai ten block moi :"))
)
(setq mau (entget snn))
(Command "clayer" (cdr(assoc 8 mau)))
(setq tencu (cdr(assoc 2 mau)))
(setq diemcu (cdr(assoc 10 mau)))
(setq diemmoi (getpoint "\n Chon diem chen moi cho Block nay :"))
(setq Trx (- (car diemmoi) (car diemcu)))
(setq Try (- (cadr diemmoi) (cadr diemcu)))
(setq Trz (- (caddr diemmoi) (caddr diemcu)))
(setq TLXc (cdr(assoc 41 mau)))
(setq TLYc (cdr(assoc 42 mau)))
(setq TLZc (cdr(assoc 43 mau)))
(setq gocquayc (/ (* (cdr(assoc 50 mau)) 180) pi))
(Command "Block" tenmoi diemmoi snn "")
(Command "Insert" tenmoi diemmoi TLXc TLYc gocquayc)
(setq ss (ssget "X" (list( cons 0 "INSERT") (cons 2 tencu))))
(setq n (sslength ss) i 0)
(while (
(setq sn (ssname ss i))
(setq ent (entget sn))
(setq TLX (cdr(assoc 41 ent)))
(setq TLY (cdr(assoc 42 ent)))
(setq TLZ (cdr(assoc 43 ent)))
(setq tam (cdr(assoc 10 ent)))
(setq gocquay (/ (* (cdr(assoc 50 ent)) 180) pi))
(setq pointX (+ (car tam) Trx))
(setq pointY (+ (cadr tam) Try))
(setq pointZ (+ (caddr tam) Trz))
(setq pointmoi (list pointX pointY pointZ))
(Command "Block" tenmoi "y" pointmoi sn "")
(Command "Insert" tenmoi pointmoi TLX TLY gocquay)
(setq i (1+ i))
)
(setvar "clayer" lay)
(command "undo" "end")
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề Đổi điểm chèn sau khi đã chèn block khắp nơi. Xem đúng bài viết #62844 để đọc hướng dẫn và trao đổi thêm.