Block list comparing to CSV file

Block list comparing to CSV file

don_scribner
Contributor Contributor
369 Views
5 Replies
Message 1 of 6

Block list comparing to CSV file

don_scribner
Contributor
Contributor

Dudes & Dudettes,

 

I am looking for a lisp that will list the blocks in a drawing but only if they are in a list (say a CSV file).  Here's the scenario.  We currently have a hardware page which pretty much includes every screw, nut, washer that we carry. We would like to display only what the installer or fabrication would need. My thought is, scan the drawing and extract the hardware block names (including nested blocks) and return only hardware.  So, the title block, item calls, rev triangles etc, would not be represented. Dumping it into a table or a spreadsheet would be bonus.  

 

Has anybody done this? 

0 Likes
370 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Is there something consistent about Block name format?  For example, if all hardware items are Blocks whose names start with "HDWR" or something, a selection could easily be made to find all of those, and ignore all other Blocks.

 

(setq HardwareBlocksOnly (ssget "_X" '((0 . "INSERT") (2 . "HDWR*"))))

 

Or, if they are always Inserted only on a certain Layer or limited number of Layers, let's say with Layer names that all start with "Hdwr," and the stuff you want ignored is always on some other Layer(s).

 

(setq HardwareBlocksOnly (ssget "_X" '((0 . "INSERT") (8 . "Hdwr*"))))

Kent Cooper, AIA
0 Likes
Message 3 of 6

don_scribner
Contributor
Contributor

Kent,

We have a lot of legacy data. To make matters worse, we were bought by a large company that came in, renumbered everything inconsistently . . . but SOME of the blocks remain the same. Plus the templates were worked on by absolutely anybody at any experience level with no gatekeeper.  So, there is no consistency:  name, prefix, layer. Absolute horror show.  That's why I figure if a list could find a block and see if it is in a file that I compiled in a common place.  If YES, add it to the list.  If NO, them move on.  I figure I'm not the first to need this and, though I have done a lot of rudimentary lisps,  I don't have the skills for this.  But, I think it's probably pretty simple for somebody that has the skills.

 

0 Likes
Message 4 of 6

pendean
Community Legend
Community Legend

@don_scribner   In modern versions of AutoCAD, the COUNT command has the ability to create a TABLE of blocks (COUNTTABLE command) in an area you select with any method you want (AutoCAD2024 is best at it): by chance, is that the basic idea of you search need in your legacy files?

 

Explore these in HELP

https://help.autodesk.com/view/ACD/2023/ENU/index.html?guid=GUID-58570EEF-5478-4017-AE39-5556BD6D69C...

 

 

0 Likes
Message 5 of 6

don_scribner
Contributor
Contributor

That appears to be a newer feature.  I am running 2021 and all I show is COUNT and BCOUNT. 

 

What I am looking for is one lisp/command/button that the team can push or click to produce the table or list.  If it takes any massaging, as many ACAD features do, the result will be inconsistent and they will be far less likely to do it.  Human nature: it has to be easy. 

 

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Just guessing, make a list of all selected block names, yes have a part list, this is made by reading a text of product codes etc. Then can do inside a double loop a compare block name with list if found add attributes to a output list. Have left out nested blocks for moment. Dont need CSV just txt as it sounds like a single column is all you are comparing to. 

 

To even start need a test.txt file and a sample dwg. 

0 Likes