Jump to content

Lisp for calculating the sum of blocks


sophie

Recommended Posts

Does anyone know of a lisp for calculating the sum of blocks? So if I was to create a block to represent trees in plan for example, I could automatically tally the number of trees.

 

With thanks,

 

Sophie

Link to comment
Share on other sites

(defun c:blc(/ blSet filLst nameLst curLen)

 (defun namesExtract(selSet)
   (mapcar '(lambda(x)(assoc 2 x))
    (mapcar 'entget(vl-remove-if 'listp
     (mapcar 'cadr(ssnamex selSet)))))
   ); end of namesExtract
 
 (princ "\n<<< Select sample blocks to count >>> ")
 (if(setq blSet(ssget '((0 . "INSERT"))))
   (progn
     (setq filLst(append(list '(0 . "INSERT"))(list '(-4 . "<OR"))
	     (namesExtract blSet)(list '(-4 . "OR>"))))
     (princ "\n<<< Specify area(s) to count >>> ")
      (if(setq blSet(ssget filLst))
 (progn
   (setq nameLst(namesExtract blSet))
   (princ "\n========== COUNT REPORT ==========")
   (while nameLst
     (setq curLen(length nameLst))
     (princ(strcat "\n" (cdar nameLst) " "
		  (itoa(- curLen(length(setq nameLst
		    (vl-remove(car nameLst)nameLst)))))))
     ); end while
   (princ "\n=========== END REPORT ===========\n")
   (textscr)
   ); end progn
 ); end if
     ); end progn
   ); end if
 (princ)
 ); end of c:blc

Link to comment
Share on other sites

Do you really need a lisp, or could you use the BCOUNT command which was recently mentioned?

 

yes bcount is the go.. and you don't need a lisp for that command..

Link to comment
Share on other sites

sophie

Forum Newbie

 

Using: AutoCAD 2004

 

Join Date: Jan 2008

Posts: 3

 

Hey good point.. Don't know if it works in autocad 2004... maybe you do need a lisp then to make it happen.. my apologies...

Link to comment
Share on other sites

yes, and AutoCAD 2004 had express tools. no?

 

Yes. But it not always good tool. For example I want to count certain blocks inside some area. Therefore I consider use of this (or another) LISP quite justified.

Link to comment
Share on other sites

  • 3 years later...

Hello,

sorry to come so late about this topic but how do you use the BlockQuantity and the BlockList?

Thanks!!

Link to comment
Share on other sites

Thanks, SLW210 :)... In fact when I enter blockquantity or blockslist, it says "blockquantity Unknown command "BLOCKQUANTITY". Press F1 for help" or "blockslist Unknown command "BLOCKSLIST". Press F1 for help."... That's why I'm asking...:?

PS: I already loaded the 2 files...:sweat:

Link to comment
Share on other sites

Are they in a folder in your support file search path? _OPTIONS>Files>Support File Search path make sure you have the path included. They both work fine here. I just checked them. Make sure your spelling is correct.

Link to comment
Share on other sites

  • 7 months later...

I am a new member of CADTutor Forum. I can not download the files you attached. Pls help! Thanks.

Post: Lisp for calculating the sum of blocks

Forum: AutoCAD Drawing Management & Output

 

Posted by: SLW210

Original Content:

I will give you 2 of mine. BCOUNT has limited functionality, though I still use it some. Mine have a few more options.
Edited by SLW210
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...