Block counting

Hi guys, I use a lot of plant and tree blocks in my drawings and usually end up counting them manually (sometimes in the thousands) I want to count the number of blocks. I have looked at similar posts but it looks like you have to insert a code into LISP, embarrassingly I do not even know what a lisp file is. Can someone please help me out with the best one to insert and how to do it. If I can get it to work it would be life changing.

Thanks in advance guys

Stephen

Comments

  • Hi Stephen,
    Have a look at the tutorial for Quick Select here:
    https://www.bricsys.com/en_AU/bricscad/tutorials/
    It allows you to select blocks by name and it shows the count.  Maybe not as sophisticated as a custom LISP program but might be a good enough answer?
    Damian
  • Thanks Damian, but that is not working for me. surly it cant be that hard I would have thought like "select similar' type funcion any thing close?
  • When I want to know have many time a block is inserted in a drawing, I open the drawing explorer > blocks, and there , every block is listed and the number of its' references.
  • Thanks jorg yep thats it! I used you actually use that a couple of years ago bu it used to lie to me:) I am assuming because I cut and paste from another drawing there wer some inviable artifacts. If anyone knows how this could have occured please let me know what to watch out for. But i checked this drawing manually and all is good. Will just take a while to get confident again.

    Thanks guys!

  • @ Stephen:
    The block count in the Drawing Explorer includes blocks that are nested.
    This 'nested block count' is not updated automatically if the parent block is deleted.

    If you want to correctly count nested block you can try this add-on:
    http://www.b-k-g.nl/bkg_countblocks.html
  • I am thinking this is a serious issue with bricscad that can cost jobs.  Cant get a real "select similar" and just get a count?
  • To clarify the 'nested block count':
    Say you have a block 'Tree'. And a block 'RowOfTrees' in which the 'Tree' block is nested 5 times.
    In your plan you have 11 inserts of the 'Tree' block and 7 inserts of the 'RowOfTrees' block.
    The total number of trees is then 11+(7*5)=46.
    But the Drawing Explorer will report 11+5=16.
  • I have downloaded it could you pls explain how to  get it loaded, I have read the instructions and do not understand. For instance I have np idea what a lisp file is

    Thank you
  • How to install BKG_SelectSimilar:
    Unpack all files from the zip file in a single folder, which does not have to be in the search path.
    In BricsCAD type _CUSTOMIZE on the command line and in the dialog box choose: File > Load partial CUI file.
    Then browse to the cui file and select it.

    You do not have to know what a Lisp file is.
  •  Hi Roy and thanks for that

    When I tried to use select similar I got: ; error : no function definition ; expected FUNCTION at [EVAL]"
    in my command line? I am running an Autocad evaluation program. Could that be the issue.

    I downloaded the select similar files (which were 4 files with a total of 24KB) when I went trough the process 'load partial cui file' there was only one file (bkg select similar) which had grown from 1KB in the original file to a single file of 3KB 

    Thank you for your patients it is appreciated

    Stephen
  •  Ok answer: is it does not work with version 12 and below

    Cheers
  • Thanks Roy for the plugins work so well!

    Stephen

  • Thank you Stephen, glad to hear it!
  • New problem same topic. I have a LISP that we have run for ages to count blocks of a certain type.

    NOW one machine hangs and gives me the following error message. Could someone help me, is there some setting I should look for ?

    All machines run the same script from the same place.

    THX / Patrik

    ERRORMESS.txtDe3.lsp

  • @Patrik Sparrman:

    This is hard to test without a dwg file that causes the problem.

    There are only two instances of (assoc 2 bkent) in the lisp file.  The error message indicates that one of the values for a multiplication operation is not a number.  My experience is that Bricscad returns one of the variables in the error message when an operation fails but the variable returned may not be the variable that caused the problem.  I would add the '(print' lines below and run the function.  I expect that one of the '(print' lines will return nil or will return something other than a number.  That will give an indication of where to look further.

    [code]      (setq fn (open fnam "a"))
    (print (cdr (assoc 1 bkent)))                                    ;;; new
    (print (itoa numbk))                                                 ;;; new
    (print (itoa (fix (* numbk (cdr (assoc 2 bkent))))))      ;;; new
          (princ (strcat "\n"
                         (cdr (assoc 1 bkent))
                         "\t"
                         (itoa numbk)
                         "\t\t"
                         (itoa (fix (* numbk (cdr (assoc 2 bkent)))))
                  )
                  fn
          )
          (close fn)
    (print rnlen)                                                ;;; new
    (print numbk)                                              ;;; new
    (print (cdr (assoc 2 bkent)))                         ;;; new
    (print)                                                         ;;; new
          (setq rnlen (+ rnlen (* numbk (cdr (assoc 2 bkent)))))[/code]
  • Thanks yes my guess to but I run this script successfully on 4 other installations and have for years. Its only one machine that hangs.

    I will try and see if I get different results from different Machines.

    Have a nice weekend

  • Hmm now she tells me this only happends after drawing for appr one hour.

    Then she has to close BC and open again then it works for a while. W7 64b this only appears on this machine.

  • @Patrik:
    In that case I would look at the configuration of the computer.  I have had the same problem of having lisp routines fail after running Bricscad for an extended time.  I have also seen built-in commands stop working after several hours.  I have reported the problem but I'm not sure the underlying problem has been found.  It would be very hard for Bricscad staff to duplicate this since it is generally not repeatable, and it seems to depend on the exact lisp functions that are being run, and it can take several hours of drawing for the problem to occur.

    The two things I have done to minimize the problem are to maximize the memory available to Bricscad.  I will have to look that up later because I can't search without losing this post.  The other is to go through all the lisp code I have and be sure that all the local variables are declared in the functions.
  • @ Patrik:
    Maybe Martin is onto something. Although there are more than 35 (!) localized variables you have missed at least 4: numbk, e, enttyp and layername.
    Two other things that are striking about the code:
    1. Frequent use of while loops. In many cases I think you can use repeat.
    2. Variables used in the sub function are localized in the main function.
    Note that these are not errors, I am mentioning them because they may help resolve the problem Martin has indicated.
  • ...
    Using (gc) to force a garbage collection may also help.
This discussion has been closed.