Chuyển đến nội dung
Diễn đàn CADViet
Đăng nhập để thực hiện theo  
engineer0405

[Nhờ chỉnh sửa] phần chọn đối tượng cho lisp

Các bài được khuyến nghị

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)
   )

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

Tạo một tài khoản hoặc đăng nhập để nhận xét

Bạn cần phải là một thành viên để lại một bình luận

Tạo tài khoản

Đăng ký một tài khoản mới trong cộng đồng của chúng tôi. Điều đó dễ mà.

Đăng ký tài khoản mới

Đăng nhập

Bạn có sẵn sàng để tạo một tài khoản ? Đăng nhập tại đây.

Đăng nhập ngay
Đăng nhập để thực hiện theo  

×