Place circles to all the blocks which has different block name and different attribute values on the same attribute tag

Place circles to all the blocks which has different block name and different attribute values on the same attribute tag

nanja_c86
Enthusiast Enthusiast
399 Views
4 Replies
Message 1 of 5

Place circles to all the blocks which has different block name and different attribute values on the same attribute tag

nanja_c86
Enthusiast
Enthusiast

Here is the Lisp from @ВeekeeCZ, i am trying to modify.

Need to look for the block name "DT_TAP2PLG,DT_TAP4PLG,DT_TAP8PLG" and Attribute tag "tap_val". need to place circles for block ins point in different colours for different attribute values and finally need to show alert msg, number of circles placed for each attribute value, segregated by blockwise.

Attaching the Dwg file for better understanding.

 

@ВeekeeCZ Please check this, this is your program which you written on my other similar post, i am trying to modify for other blocks. its counting and placing circles but not by block name wise.

Please help.

 

(defun c:tap_eq ( / r e i e l a v c);
(setq r '(("DT_TAP2PLG" . ": 2port")
("DT_TAP4PLG" . ": 4port")
("DT_TAP8PLG" . ": 8port")))


(if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (mapcar '(lambda (x) (strcat (car x) ",")) r))) '(8 . "NS_RF CONSTRUCTION" )(cons 410 (getvar 'ctab)))))
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(if (not (vl-catch-all-error-p (setq v (vl-catch-all-apply 'getpropertyvalue (list e "tap_val")))))
(setq l (if (setq a (assoc v l))
(subst (append a (list e)) a l)
(cons (list v e) l))))))
(if l
(progn
(if (setq a (assoc "" l)) (setq l (subst (cons "BLANK" (cdr a)) a l)))
(setq c 0 l (vl-sort l '(lambda (u v) (> (length u) (length v)))))
(foreach v l
(setq c (1+ c))
(foreach e (cdr v)
(entmake (list '(0 . "CIRCLE") (assoc 10 (entget e)) '(8 . "circles") '(40 . 25) '(370 . 40) (cons 62 c)))))
(alert (apply 'strcat (mapcar '(lambda (x) (strcat "\n" (car x) " - " (itoa (1- (length x))) " circles placed.")) l)))))
(princ)
)


Thank you.

0 Likes
400 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Post 2 dwgs, states before and after.

0 Likes
Message 3 of 5

nanja_c86
Enthusiast
Enthusiast

I don't want to change anything in drawing. Need to count the number of blocks with attribute values and should show alert msg.

see the attached image for better understanding.

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant
(defun c:tap_eq ( / r e i e l a v c);
  
  (setq r '(("DT_TAP2PLG" . ": 2port")
	    ("DT_TAP4PLG" . ": 4port")
	    ("DT_TAP8PLG" . ": 8port")))
  
  (if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (mapcar '(lambda (x) (strcat (car x) ",")) r))) '(8 . "NS_RF CONSTRUCTION" ) (cons 410 (getvar 'ctab)))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (if (not (vl-catch-all-error-p (setq v (vl-catch-all-apply 'getpropertyvalue (list e "tap_val")))))
	(setq l (if (setq a (assoc v l))
		  (subst (append a (list e)) a l)
		  (cons (list v e) l))))))
  (if l
    (progn
      (if (setq a (assoc "" l)) (setq l (subst (cons "BLANK" (cdr a)) a l)))
      (setq c 0 l (vl-sort l '(lambda (u v) (> (length u) (length v)))))
      (foreach v l
	(setq c (1+ c))
	(foreach e (cdr v)
	  (entmake (list '(0 . "CIRCLE") (assoc 10 (entget e)) '(8 . "circles") '(40 . 25) '(370 . 40) (cons 62 c)))))
      (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(40 . 15) (cons 10 (trans (getpoint "\nPlace the text: ") 1 0))
		      (cons 1 (apply 'strcat (mapcar '(lambda (x) (strcat "\n" (car x) " - " (itoa (1- (length x))) " circles placed.")) l)))))))
  (princ)
  )
0 Likes
Message 5 of 5

nanja_c86
Enthusiast
Enthusiast

Its works same as before lisp, except places mtext in autocad. But what i need is need to segregate block wise

there are 3 different blocks with same attribute tag and value. Need to count for each block and display message separately by block wise.

Placing text is a good idea.  But for me Alert msg window is fine.

0 Likes