- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I use this LISP to count how many blocks there is inside my dwg.
I attached 2 jpeg to make more understandable.
The first one, (IMG_01) there's 3 blocks (A, B and C). And the text next to them count how many of them there is on my DWG.
The second one (IMG_02) shows the same blocks, but they are inside another block (let's call it ABC). When I use the recount LISP, it shows 0.
Is there a way to make this LISP comand to count those blocks when they are inside another block?
Here's the LISP recount I use.
(defun c:recount (/ block_list cnt env_name) (setq block_list (list (cons '2 "A") (cons '2 "B") (cons '2 "C") ) ) (foreach i block_list (if (setq ss (ssget "X" (list '(0 . "INSERT") i))) (progn (setq cnt (itoa (sslength ss)) env_name (strcat "BLOCK_COUNT_" (cdr i)) ) (setenv env_name cnt) (princ (strcat "\nSet " env_name " to " cnt)) ) (progn (setq cnt "0" env_name (strcat "BLOCK_COUNT_" (cdr i)) ) (setenv env_name cnt) (princ (strcat "\nSet " env_name " to " cnt)) ) ) ) (command "_REGEN") ;_refreshes field values (princ) )
And here's DieselExpression I use on the texts next to the blocks (to count the block "A", for example)
$(getenv, BLOCK_COUNT_A)
I've done all this using this topic as reference, but my knowledge using LISP is very limited to help with my issue.
Solved! Go to Solution.