View Full Version : Lisp for calculating the sum of blocks
sophie
5th Mar 2008, 12:42 pm
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
ASMI
5th Mar 2008, 01:04 pm
(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
LElkins
5th Mar 2008, 01:05 pm
Do you really need a lisp, or could you use the BCOUNT command which was recently mentioned?
khama
5th Mar 2008, 01:34 pm
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..
ASMI
5th Mar 2008, 01:35 pm
sophie
Forum Newbie
Using: AutoCAD 2004
Join Date: Jan 2008
Posts: 3
NBC
5th Mar 2008, 01:52 pm
Bcount became available in AutoCAD 2000 though, according to this - http://www.hyperpics.com/commands/
ASMI
5th Mar 2008, 01:55 pm
Yes, with Express Tools.
LElkins
5th Mar 2008, 01:58 pm
yes, and AutoCAD 2004 had express tools. no?
khama
5th Mar 2008, 02:12 pm
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...
ASMI
5th Mar 2008, 02:19 pm
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.
SLW210
5th Mar 2008, 03:56 pm
I will give you 2 of mine. BCOUNT has limited functionality, though I still use it some. Mine have a few more options.
sophie
5th Mar 2008, 06:48 pm
Thanks for that, certainly works. I'll remember the bcount command for using a latter version.
vidada
9th May 2011, 09:49 am
Hello,
sorry to come so late about this topic but how do you use the BlockQuantity and the BlockList?
Thanks!!
SLW210
9th May 2011, 02:11 pm
You could send me $1,000,000 US or read this.....How to Use LISP Routines (http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive)
vidada
10th May 2011, 04:12 am
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:
SLW210
10th May 2011, 12:47 pm
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.
vidada
11th May 2011, 01:12 am
Done!! :D:D... Thanks very much, SLW210!!!
LAM BOI CO
23rd Dec 2011, 03:46 am
I am a new member of CADTutor Forum. I can not download the files you attached. Pls help! Thanks.[/quote]
Post: Lisp for calculating the sum of blocks (http://www.cadtutor.net/forum/showthread.php?20920&p=133463#post133463)
Forum: AutoCAD Drawing Management & Output
Posted by: SLW210 (http://www.cadtutor.net/forum/member.php?5903-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.
SLW210
23rd Dec 2011, 02:02 pm
I have no problem down loading them.
Must be blocked on your end.
What message do you get?
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.