BCOUNT - Block reporting tool
#1
Posted 01 March 2020 - 12:07 PM
For example: If I have many shapes and solids in my design, but all my electronics are blocks.
I want to be able to see how many of each part I have in my design, like MAINSRELAYS 10, ARDUINONANO 4, BTS7960 4, etc
In AutoCAD, I think this tool is called BCOUNT, but I don't mind how it works or what it's called.
If anybody has any VBA code that can do this, I would appreciate it too.
#2
Posted 01 March 2020 - 01:29 PM
What version of NC do you use?
#3
Posted 02 March 2020 - 08:49 AM
Nanocad 5 does not take LISP (as far as I know), but by exporting to DXF (* .DXF = text> * .CSV) this allows the content to be processed using a spreadsheet.
This requires taking into account the syntax of the DXF and developing a spreadsheet with BNBVAL and other functions, ... (or VBA) functions.
Otherwise see with the Pro versions of Nanocad for the LISP and the VBA.
Cordialy
Patrick
#4
Posted 02 March 2020 - 11:48 AM
in http://ma83.free.fr/info/acadlisp.htm
Nbloc.lsp to load in Nanocad pro 11 (trial)
NBLOC.LSP . The NBLOC program displays the number of blocks that are contained in
the drawing. Information can be simply screen or saved
in a file which will have the extension "NBL". This file will be placed
in the same directory as the DWG file.
;NBLOC
(defun c:NBLOC ()
(initget "O N")
(setq choix (getkword "\nDésirez-vous créer un fichier contenant le nombre de bloc ? O/N: "))
(setq bl (list (cdr (assoc 2 (tblnext "block" T)))))
(setq nombl T)
(while (/= nombl nil)
(setq nombl (tblnext "block"))
(if (/= nombl nil)
(setq bl (append bl (list (cdr (assoc 2 nombl)))))
)
)
(setq compte 0)
(setq nb (length bl))
(setq f (open (strcat (getvar "dwgname") ".nbl") "w"))
(repeat nb
(setq ent (ssget "x" (list (cons 0 "INSERT") (cons 2 (nth compte bl)))))
(if (/= ent nil)
(setq nbloc (sslength ent))
(setq nbloc 0)
)
(princ (strcat "\n" (nth compte bl) " = " (itoa nbloc)))
(if (= choix "O")
(progn
(princ (nth compte bl) f)
(princ " = " f)
(princ nbloc f)
(princ "\n" f)
)
)
(setq compte (1+ compte))
)
(close f)
(if (= choix "O")
(princ (strcat "\nLe fichier contenant la liste des bloc se nomme: " (getvar "dwgname") ".NBL"))
)
(princ)
)
(princ "\n==> NBLOC")
(princ)
#5
Posted 03 March 2020 - 10:28 AM
Kreator, on 01 March 2020 - 01:29 PM, said:
What version of NC do you use?
Hi Keator, I'm using NanoCAD Pro x64bit v11.0.4761.8897 (build 4866).
pguimber, on 02 March 2020 - 08:49 AM, said:
Nanocad 5 does not take LISP (as far as I know), but by exporting to DXF (* .DXF = text> * .CSV) this allows the content to be processed using a spreadsheet.
This requires taking into account the syntax of the DXF and developing a spreadsheet with BNBVAL and other functions, ... (or VBA) functions.
Otherwise see with the Pro versions of Nanocad for the LISP and the VBA.
Cordialy
Patrick
Thanks Patrick, I will try that out. Pro 11 supports VBScript Jscript and LISP as far as I have found. I wrote a cell report tool that makes a CSV file for MicroStation in VBA because it was a lacking feature in v8 too.
If this doesn't work and I can't find any other solutions, I think I'll try that next.
#6
Posted 03 March 2020 - 11:23 AM
- Use Select similar command - SELECTSIMILAR. You can find the button in the Properties window (Ctrl+1). Choose 1 block, then choose similar and you'll see the count. But that can only be used for same layer/color etc.
- Use Selection window - SHOWTABQS. Here you can choose Blocks and choose the name of desired one to count. You'll see count of the blocks in the bottom of the window.
- Use reports - tables, that collect objects by filter. Use Table - Report, name it, then press Select to add filter. Then choose Blocks and any other filters you need.
- After that leave only Name field checked (you don't need other properties in the table just to count them). You'll get a table with all blocks in rows.
- Now you need to combine and count them - get into the table (edit it). Group column A by name.
- And the last - add column B. Name it "Count". Type =count() in the B column in the Report template section (right to the green cell). Now close and enjoy! You can save the table to your template or add it to tools pallete to use it anywhere later (no need to make it all every time).
Attached Files
#7
Posted 03 March 2020 - 11:33 AM
I had already tried 4 other LISP files that didn't work at all.
It did not let me save the list due to an error I'm not smart enough to fix yet, but it still printed the results to the CommandLine. This will be enough to get me going.
I've edited the file to disable saving the list and translated it to English if anybody else needs it. This one is called NBLOCK (to distinguish itself from the original).
;NBLOCK ;English Adaptation of NBLOC without file-saving. - which doesn't work in nanoCAD 11 for some reason (defun c:NBLOCK () (setq bl (list (cdr (assoc 2 (tblnext "block" T))))) (setq nombl T) (while (/= nombl nil) (setq nombl (tblnext "block")) (if (/= nombl nil) (setq bl (append bl (list (cdr (assoc 2 nombl))))) ) ) (setq compte 0) (setq nb (length bl)) (repeat nb (setq ent (ssget "x" (list (cons 0 "INSERT") (cons 2 (nth compte bl))))) (if (/= ent nil) (setq nblock (sslength ent)) (setq nblock 0) ) (princ (strcat "\n" (nth compte bl) " = " (itoa nblock))) (setq compte (1+ compte)) ) (princ) ) (princ "\n==> NBLOCK") (princ)
#8
Posted 03 March 2020 - 11:37 AM
I've been doing it with selection tools one block at a time for now, but my files can have up to 50 different blocks and I can't always remember which ones. I need a solution that can find them all and list them very quickly for my work.
I will keep this in mind as a backup option.
#9
Posted 03 March 2020 - 12:34 PM
Johandre, on 03 March 2020 - 11:37 AM, said:
I need a solution that can find them all and list them very quickly
https://cloud.mail.r.../2FTv/27NrVD1vo
#10
Posted 03 March 2020 - 12:43 PM
Kreator, on 03 March 2020 - 12:34 PM, said:
https://cloud.mail.r.../2FTv/27NrVD1vo
This is great! I didn't realise that it's a live-updating table! I copied it into my project as you suggested and am very happy with this. Thanks for making the effort of recording a video too.
I'll play with tables some more!
#11
Posted 03 March 2020 - 01:09 PM
Yeah, read more about tables in NC - they are not just like boring tables, they are Excel-like and integrated into drawing database.
#12
Posted 04 March 2020 - 01:01 AM
I'd like to be able to report the block's description and material too, since I think those are properties associated with blocks in nanoCAD, from what I can see in the Properties and Block menus, but those aren't options in the tables.
I was going to put the weight of every block in the description, then tally that too using formulas.
I tried making the Block Name look like this: "Block Name - Product Serial Number - Weight - Material - Brand" and run a string interpreter on it in the table, but I haven't found an option to split strings from tables.
I'd also like to be able to list nested blocks somehow - those seem to be excluded from the count in the table.
If we can somehow do these things, it would be a dream come true!
#13
Posted 04 March 2020 - 08:21 AM
Johandre, on 04 March 2020 - 01:01 AM, said:
I was going to put the weight of every block in the description, then tally that too using formulas.
I tried making the Block Name look like this: "Block Name - Product Serial Number - Weight - Material - Brand" and run a string interpreter on it in the table, but I haven't found an option to split strings from tables.
Johandre, on 04 March 2020 - 01:01 AM, said:
If we can somehow do these things, it would be a dream come true!
#14
Posted 04 March 2020 - 10:36 AM
Kreator, on 04 March 2020 - 08:21 AM, said:
If only I could somehow insert groups as easily as blocks. Another problem for another day I think.
Kreator, on 04 March 2020 - 08:21 AM, said:
#15
Posted 19 September 2021 - 07:56 AM
Johandre, on 04 March 2020 - 10:36 AM, said:
Attached Files
See more about the capabilities of nanocad
table | uMarker | mechWizard
#16
Posted 22 September 2021 - 02:52 AM
Johandre, on 03 March 2020 - 12:43 PM, said:
This example shows the capabilities of nanocad and the associativity of objects using the example of blocks
https://www.youtube....C2xb0Au&index=2
- Automatic dynamic block counting
- Grouping blocks on a specific layer
- Automatic block numbering
- Automatic control of the visibility parameter from tabular reports
- And some more functions
Attached Files
See more about the capabilities of nanocad
table | uMarker | mechWizard
#17
Posted 08 November 2022 - 04:22 AM
Maybe the developer never imagined not even in his wildest dreams that we would need to count things after do the project?
PS: Dont feel sad NanoCAD, those incompetents from AutoCAD also didnt think about this.
#18
Posted 08 November 2022 - 04:34 AM
Alx Synth, on 08 November 2022 - 04:22 AM, said:
(24) ⚡ Dialogue for configuring the display of report properties - YouTube
What exactly do you want to count
See more about the capabilities of nanocad
table | uMarker | mechWizard
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users