I like what you guys are up too. Such intelligent work and reporting! Carry on the superb works guys Iˇve incorporated you guys to my blogroll. I think it"ll improve the value of my site :)
em chào các anh ạ
em có 1 lisp như thế này ạ
(defun c:eb (/ blk)
;;;---------------------------------------------------------------------;;;
;;;A rewrite of the entsel function. ;;;
;;;---------------------------------------------------------------------;;;
(defun ent_sel (msg / ent)
(while (not ent)
(cond ((setq ent (entsel msg)))
((= (getvar "ErrNo") 7)
(princ "\nSelection missed. Please try again.")
)
((= (getvar "ErrNo") 52) (exit))
)
)
ent
)
;;;
;;;
;;;
(while (not blk)
(setq blk (car (ent_sel "\nSelect Block: ")))
)
(mapcar '(lambda (x)
(and
(vlax-property-available-p x 'explodable)
(eq (vlax-get-property x 'explodable) :vlax-false)
(not (vlax-put-property x 'explodable :vlax-true))
(princ "\nThe selected Block is now Explodable! ")
)
)
(list
(vla-item (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(cdr (assoc 2 (entget blk)))
)
)
)
(princ)
)
nhưng phần chọn ban đầu em chưa thấy hợp lý lắm (chỉ chọn đc từng block 1)
mong các anh chỉnh giúp em với
-Phần chọn đối tượng:
b1:chọn đối tượng(đoạn này mình chọn tất cả ( gồm line, text, block,....)
b2:lọc các đối tượng mình vừa chọn chỉ giữ lại các block
b3:thực hiện lệnh
b4:kết thúc
mong các anh hoàn chỉnh giúp em 2 bước đầu với ạ
em cảm ơn các anh
(defun c:eb (/ blk)
;;;---------------------------------------------------------------------;;;
;;;A rewrite of the entsel function. ;;;
;;;---------------------------------------------------------------------;;;
(defun ent_sel (msg / ent)
(while (not ent)
(cond ((setq ent (entsel msg)))
((= (getvar "ErrNo") 7)
(princ "\nSelection missed. Please try again.")
)
((= (getvar "ErrNo") 52) (exit))
)
)
ent
)
;;;
;;;
;;;
(while (not blk)
(setq blk (car (ent_sel "\nSelect Block: ")))
)
(mapcar '(lambda (x)
(and
(vlax-property-available-p x 'explodable)
(eq (vlax-get-property x 'explodable) :vlax-false)
(not (vlax-put-property x 'explodable :vlax-true))
(princ "\nThe selected Block is now Explodable! ")
)
)
(list
(vla-item (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(cdr (assoc 2 (entget blk)))
)
)
)
(princ)
)
(defun c:eb (/ blk)
;;;---------------------------------------------------------------------;;;
;;;A rewrite of the entsel function. ;;;
;;;---------------------------------------------------------------------;;;
(defun ent_sel (msg / ent)
(while (not ent)
(cond ((setq ent (entsel msg)))
((= (getvar "ErrNo") 7)
(princ "\nSelection missed. Please try again.")
)
((= (getvar "ErrNo") 52) (exit))
)
)
ent
)
;;;
;;;
;;;
(while (not blk)
(setq blk (car (ent_sel "\nSelect Block: ")))
)
(mapcar '(lambda (x)
(and
(vlax-property-available-p x 'explodable)
(eq (vlax-get-property x 'explodable) :vlax-false)
(not (vlax-put-property x 'explodable :vlax-true))
(princ "\nThe selected Block is now Explodable! ")
)
)
(list
(vla-item (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(cdr (assoc 2 (entget blk)))
)
)
)
(princ)
)
(defun c:eb (/ blk)
;;;---------------------------------------------------------------------;;;
;;;A rewrite of the entsel function. ;;;
;;;---------------------------------------------------------------------;;;
(defun ent_sel (msg / ent)
(while (not ent)
(cond ((setq ent (entsel msg)))
((= (getvar "ErrNo") 7)
(princ "\nSelection missed. Please try again.")
)
((= (getvar "ErrNo") 52) (exit))
)
)
ent
)
;;;
;;;
;;;
(while (not blk)
(setq blk (car (ent_sel "\nSelect Block: ")))
)
(mapcar '(lambda (x)
(and
(vlax-property-available-p x 'explodable)
(eq (vlax-get-property x 'explodable) :vlax-false)
(not (vlax-put-property x 'explodable :vlax-true))
(princ "\nThe selected Block is now Explodable! ")
)
)
(list
(vla-item (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(cdr (assoc 2 (entget blk)))
)
)
)
(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 244777_eb.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 EB để chạy lisp.
Mã nguồn 244777_eb.lsp (trích từ bài viết gốc)
(defun c:eb (/ blk)
;;;---------------------------------------------------------------------;;;
;;;A rewrite of the entsel function. ;;;
;;;---------------------------------------------------------------------;;;
(defun ent_sel (msg / ent)
(while (not ent)
(cond ((setq ent (entsel msg)))
((= (getvar "ErrNo") 7)
(princ "\nSelection missed. Please try again.")
)
((= (getvar "ErrNo") 52) (exit))
)
)
ent
)
;;;
;;;
;;;
(while (not blk)
(setq blk (car (ent_sel "\nSelect Block: ")))
)
(mapcar '(lambda (x)
(and
(vlax-property-available-p x 'explodable)
(eq (vlax-get-property x 'explodable) :vlax-false)
(not (vlax-put-property x 'explodable :vlax-true))
(princ "\nThe selected Block is now Explodable! ")
)
)
(list
(vla-item (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(cdr (assoc 2 (entget blk)))
)
)
)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ chỉnh sửa] phần chọn đối tượng cho lisp. Xem đúng bài viết #244777 để đọc hướng dẫn và trao đổi thêm.