Jump to content

Lisp Routine to count blocks with added attributes


ahank

Recommended Posts

I've tried several lisp routines to help count blocks that are color coded and also have a given attribute; but all the routines require me to select each block.

 

Is there a lisp routine that will count all blocks/ attributes within model space (only) and export to a table (or even better an Excel sheet)?

I want to include in the lisp routine what blocks to look for...

 

I'm a novice looking for a lot of help and would be greatly appreciated!!!

Link to comment
Share on other sites

You hinted you looked at various lisps but using a filter will do what you want when selecting blocks looking at this snippet of code it has its filter set to a block of a certain name and must be in Modelspace. Once you have the selection set you can delve deeper and check the attribute value and count up.

 

(defun getblk (bname / ss1)
(setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 "Modelspace"))))
(princ (sslength ss1)) ; total number of blocks with that name found
(do something here total up attributes)
)
;This will get all blocks called Fred
(getblk "Fred")
 
; multiple runs
(getblk "Fred")
(getblk "Part56")
(getblk "Obj32")

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...