Modification on Given LISP

Modification on Given LISP

fkp7057
Advocate Advocate
1,366 Views
22 Replies
Message 1 of 23

Modification on Given LISP

fkp7057
Advocate
Advocate

Hello, I found below the old lisp routine in this forum.

 

this lisp counts specific blocks from the entire drawing. But want it to count only block which are in model space.
Link of the original post  : LINK 

(defun c:recount (/ block_list cnt env_name)
(setq block_list
(list
(cons '2 "1")
(cons '2 "2")
(cons '2 "3")
)
)
(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)
)

 

 

0 Likes
Accepted solutions (1)
1,367 Views
22 Replies
Replies (22)
Message 21 of 23

fkp7057
Advocate
Advocate

Ok, then what is the difference ?... mean how can this help me in compare to previous code?

 

0 Likes
Message 22 of 23

Sea-Haven
Mentor
Mentor

There are ways of counting blocks in one go using a single ssget filter of block names s1,s2,s3 I guess that is what I was getting at, lee-mac has a good block counter you would just modify the selection filter rather than pick, to uses known block names.

 

I have count blocks with attributes but it sorts on block names and attributes for the count up to 5 attributes deep. 

0 Likes
Message 23 of 23

fkp7057
Advocate
Advocate

@hak_vz 

plze chek this new post.

little further modification is required here .

Link

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/block-count-and-link-with-field-text...

0 Likes