Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

block counting 1

Status
Not open for further replies.

shadow

Computer
Mar 1, 2001
321
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 if everyone helps everybody the world will be a better place
 
Replies continue below

Recommended for you

The offending code in the above code is :

(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.
 
how would i go about setting this routine to have its own default text style to use
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor