block counting
block counting
(OP)
ok i found this lisp routine not sure how its supposed to work but im assuming its supposed to count the blocks and insert it as text in the drawing at a user specified point
;;; BLKCNTa.LSP
;;; Count All Blocks Placed in Drawing
(defun C:BLKCNTA (/ FILE BLIST BNAME SS1 NUM# IN)
(setvar "cmdecho" 0)
(setq startPt (getpoint "Pick Text Starting Point .."))
(command "text" startPt "" "Blocks in this Drawing")
(setq BLIST (tblnext "BLOCK" T) IN 0)
(while BLIST
(setq BNAME (cdr (assoc 2 BLIST)))
(setq SS1 (ssget "x" (list (cons 0 "INSERT") (cons 2 BNAME))))
(if (/= SS1 nil) (progn
(setq NUM# (sslength SS1))
(setq PRTXT (strcat (itoa NUM#) " = " BNAME))
(command "text" "" PRTXT)
))
(setq BLIST (tblnext "BLOCK"))
(grtext -2 (strcat "Counting: " (itoa IN)))
(setq IN (1+ IN))
);;while
(alert "Block Count Completed!")
(princ)
)
someone take a look at it and see if they can get it to work as it is now all i get is the same as the text command
;;; BLKCNTa.LSP
;;; Count All Blocks Placed in Drawing
(defun C:BLKCNTA (/ FILE BLIST BNAME SS1 NUM# IN)
(setvar "cmdecho" 0)
(setq startPt (getpoint "Pick Text Starting Point .."))
(command "text" startPt "" "Blocks in this Drawing")
(setq BLIST (tblnext "BLOCK" T) IN 0)
(while BLIST
(setq BNAME (cdr (assoc 2 BLIST)))
(setq SS1 (ssget "x" (list (cons 0 "INSERT") (cons 2 BNAME))))
(if (/= SS1 nil) (progn
(setq NUM# (sslength SS1))
(setq PRTXT (strcat (itoa NUM#) " = " BNAME))
(command "text" "" PRTXT)
))
(setq BLIST (tblnext "BLOCK"))
(grtext -2 (strcat "Counting: " (itoa IN)))
(setq IN (1+ IN))
);;while
(alert "Block Count Completed!")
(princ)
)
someone take a look at it and see if they can get it to work as it is now all i get is the same as the text command
if everyone helps everybody the world will be a better place





RE: block counting
(grtext -2 (strcat "Counting: " (itoa IN)))
Remove that line and it should work flawlessly, assuming of course you already have defined a default text style with a fixed height, otherwise the routine will behave erratically due to the required parameters for the text command.
RE: block counting
so say something like
1st it looks for a text style called "blkcnta" set to a default height of what ever and if its not there it creates it
2nd sets it current then runs the above command with the string "(grtext -2 (strcat "Counting: " (itoa IN)))" removed
if everyone helps everybody the world will be a better place