Jump to content

adding text entities


Jessica28

Recommended Posts

I'm running autocad MEP 2014. I was for a lisp routine that'll add the quantity of pieces of text in a drawing. All my posts lately have been about adding something.....Basically I have drawings with multiple pieces of text in them. the number 20 written hundreds of times. the number 25 written hundreds of times, and so on....I'm not looking for a routing that totals them up, but a routing that'll tell me how many instances there are of each.....Right now I go to properties, then quick select, then I select text, I click on contents and then I put in a value....And I do this for every number. That's a lot of work. Is there a routine that can simplify this process? Or maybe cad can do it with a command that already exists that I don't know about?

 

 

Thanks, Jess

Link to comment
Share on other sites

Try this UNTESTED routine and let me know .

 

(defun c:Test (/ st ss)
 (if
   (and (/= (setq st (getstring t "\n Specify string to search for :"))
            ""
        )
        (setq ss (ssget "_X" (list '(0 . "*TEXT") (cons 1 st)(cons 410 (getvar 'ctab)))))
   )
   (progn
    (alert (strcat "You have < "
                   (itoa (sslength ss))
                   " > of your input string "
           )
    )
    (sssetfirst nil ss))
    (alert "Nothing found <!>")
 )
 (princ)
)

Edited by Tharwat
Link to comment
Share on other sites

Awesome. Yes it does work.....Is there any way that the routine can be modified so that when it gives me a total it also selects them so I can move them aside and delete them and move on to the next number? The reason for this is so its easier for me to chose which number I want to count next...If its cluttered with all the other numbers that I already counted its harder to find new numbers....Ideally I'd like to select the whole drawing with a command and it would populate a total list of everything.. : )

Link to comment
Share on other sites

Yes. It worked! that's great! That saves me sooo many steps...Thank you.. Hopefully next I can find something that'll do all the numbers at once. You guys keep making my job easier and easier. Lol

Link to comment
Share on other sites

Yes. It worked! that's great! That saves me sooo many steps...Thank you.. Hopefully next I can find something that'll do all the numbers at once. You guys keep making my job easier and easier. Lol

 

Excellent , Good luck . :D

Link to comment
Share on other sites

  • 2 weeks later...

Dear Mr.Tharwat,

 

i am looking for a lisp to add the text. You are kind & helping lot of peoples in this forum and I hope you could help me on this.

 

I don't know how to explain this, So i have attached a sample.

 

Want to add the plant annotation and tabulate the results or export to txt file.

 

Thanks

 

Manohar.

PLANTING.dwg

Link to comment
Share on other sites

Dear Mr.Tharwat,

 

i am looking for a lisp to add the text. You are kind & helping lot of peoples in this forum and I hope you could help me on this.

 

I don't know how to explain this, So i have attached a sample.

 

Want to add the plant annotation and tabulate the results or export to txt file.

 

Thanks

 

Manohar.

 

Something like this ?

 

(defun c:Test (/ s i e f o x y l lst)
 ;;    Tharwat 18. mar. 2014    ;;
 (princ "\n Select texts to export to txt file :")
 (if (setq s (ssget '((0 . "TEXT") (1 . "#*"))))
   (progn (setq o (open (setq f (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".txt")) "w"))
          (write-line (strcat "DESCRIPTION" "\t" "QTY") o)
          (repeat (setq i (sslength s))
            (setq e (entget (ssname s (setq i (1- i))))
                  x (cdr (assoc 1 e))
                  b ""
            )
            (while (wcmatch (setq a (substr x 1 1)) "1,2,3,4,5,6,7,8,9,0")
              (setq b (strcat b a)
                    x (substr x 2)
              )
            )
            (if (setq y (assoc (setq x (substr x 2)) l))
              (setq l (subst (cons x (+ (atof b) (cdr y))) y l))
              (setq l (cons (cons x (atof b)) l))
            )
          )
          (foreach x l (write-line (strcat (car x) "\t" (rtos (cdr x) 2 1)) o))
          (close o)
          (startapp "notepad.exe" f)
   )
 )
 (princ)
)

Edited by Tharwat
Link to comment
Share on other sites

Something like this ?

 

 

Thanks for the quick response.

Sorry I could not able to put what i need in thread.

 

Current Result

 

DESCRIPTION QTY

1 T/AZA.I 1

10 G/ALT.A 1

3 P/PHO.D 1

12 P/RHA.E 1

5 P/RHA.E 1

1 P/RHA.E 1

2 P/PHO.D 1

36 G/ALT.A 1

1 T/PLU.O 2

 

 

Desired Result

 

DESCRIPTION QTY

T/AZA.I 1

G/ALT.A 46 (36+10)

P/RHA.E 18 (12+5+1)

P/PHO-D 5 (3+2)

T/PLU.O 2 (1+1)

Edited by manohar
Link to comment
Share on other sites

I updated the codes above , try it and let me know .

 

Wow.

 

Working Great. I really apprecaite your help. it is going to save lot of my time.

 

Thanks a Lot.

 

Manohar

Link to comment
Share on other sites

Wow.

 

Working Great. I really apprecaite your help. it is going to save lot of my time.

 

Thanks a Lot.

 

Manohar

 

Excellent , You're welcome Manohar and I am happy to help. :)

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...