Counting Blocks in a Drawing

Counting Blocks in a Drawing

seedstudiolandscapedesign
Enthusiast Enthusiast
1,243 Views
7 Replies
Message 1 of 8

Counting Blocks in a Drawing

seedstudiolandscapedesign
Enthusiast
Enthusiast

I'm looking for a simple way to count blocks of various names and have the qty of each listed in one command.  Exporting to a .csv file is an added bonus.

 

What would be the best way to accomplish this in the full version of AutoCAD for Mac?

0 Likes
1,244 Views
7 Replies
Replies (7)
Message 2 of 8

martti.halminen
Collaborator
Collaborator

 

A little search could probably find several programs already doing this, but it is not all that difficult to do.

 

- On a Mac you are limited to non-ActiveX tools.

 

So, collect all the block instances into a selection set:

 

(setq ss (ssget "X" (list (cons 0 "INSERT"))))

 

Iterate through the selection set, extract the block names and collect them into two lists:

- one a list of just the names (no duplicates allowed)

- the other an association list of names and the count so far. When adding a new instance, fetch the previous count and add a new item with the count incremented.

 

Finally, collect the results by using the list of names to query the association list with ASSOC.

 

(this was assuming you don't need the blocks inside blocks, anonymous blocks etc.)

 

-- 

 

0 Likes
Message 3 of 8

3wood
Advisor
Advisor

You can try BCOUNT if they are not dynamic blocks.

0 Likes
Message 4 of 8

seedstudiolandscapedesign
Enthusiast
Enthusiast

Hi Martti,

 

This is intriguing, how do I run this command?  I do not need nested blocks, just an entry for each name and the qty in the drawing or selected area.  Any further advice would be appreciated.

 

I am a total newbie to the language and do not have any LISP experience.  I'd prefer a command, but this just dosent seem available, pretty glaring omission from such an expensive piece of software IMHO.

0 Likes
Message 5 of 8

seedstudiolandscapedesign
Enthusiast
Enthusiast

BCOUNT does not seem to be available in AutoCAD for Mac.

0 Likes
Message 6 of 8

martti.halminen
Collaborator
Collaborator

@Anonymous wrote:

Hi Martti,

 

This is intriguing, how do I run this command?  I do not need nested blocks, just an entry for each name and the qty in the drawing or selected area.  Any further advice would be appreciated.

 

I am a total newbie to the language and do not have any LISP experience.  I'd prefer a command, but this just dosent seem available, pretty glaring omission from such an expensive piece of software IMHO.


- That was written on the assumption of some programming background. One reasonably good place to start learning is http://www.afralisp.net

 

Some of the existing commands you could use are BCOUNT and EATTEXT, see http://forums.autodesk.com/t5/autocad-express-tools/i-need-to-count-blocks-in-a-drawing/td-p/1635425 for details.

 

- BCOUNT seems to be an Express Tool, do you have those loaded? (or do they even exist for Mac?)

 

[There seems to be a nice program by Lee Mac that would do just what you need, but it is written using ActiveX tools so won't work on a Mac.]

 

-- 

 

0 Likes
Message 7 of 8

martti.halminen
Collaborator
Collaborator

@Anonymous wrote:

Hi Martti,

 

This is intriguing, how do I run this command?  I do not need nested blocks, just an entry for each name and the qty in the drawing or selected area.  Any further advice would be appreciated.

 

I am a total newbie to the language and do not have any LISP experience.  I'd prefer a command, but this just doesn't seem available, pretty glaring omission from such an expensive piece of software IMHO.


- That was written on the assumption of some programming background. One reasonably good place to start learning is http://www.afralisp.net

 

Some of the existing commands you could use are BCOUNT and EATTEXT, see http://forums.autodesk.com/t5/autocad-express-tools/i-need-to-count-blocks-in-a-drawing/td-p/1635425 for details.

 

- BCOUNT seems to be an Express Tool, do you have those loaded? (or do they even exist for Mac?)

 

[There seems to be a nice program by Lee Mac that would do just what you need, but it is written using ActiveX tools so won't work on a Mac.]

 

-- 

 

0 Likes
Message 8 of 8

seedstudiolandscapedesign
Enthusiast
Enthusiast

Thanks Martti, I'll take a look at the link you referenced for some beginner tips.

 

I was using EATTEXT for this on AutoCAD for Windows, however neither EATTEXT or BCOUNT is available on the Mac version.

0 Likes