Lisp for numbers counting

Lisp for numbers counting

Anonymous
Not applicable
5,875 Views
10 Replies
Message 1 of 11

Lisp for numbers counting

Anonymous
Not applicable

Hi everyone,

 

May someone help me with a lisp that :

 

I have text numbers in text and multi line text and Autocad table,

 

I want by clicking the numbers it will add them and let me specify what size I want the summary text to be and add it to the drawing.

 

** For another clarification:

 

1.jpg

 

Thank you very much for your help.

 

0 Likes
Accepted solutions (1)
5,876 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

Hi,

 

Does anyone know how to do this lisp?

 

I just need a lisp that by clicking a text with numbers ( in a table or regular text or multiline text) , it will summarise the numbers and let me enter the result of the numbers in the drawing.

 

Please help me with it , It will be very usefull for me.

 

Thank you,

Eyal

 

0 Likes
Message 3 of 11

hencoop
Advisor
Advisor

I have a routine that does most of what you want as it is but with TEXT objects only.  The selection method filters for only TEXT objects.  Each text object must contain only one number.  It can have many words but only one number in the format of either an integer or a real.  You can get the routine for free here: sumtextnos.lsp  It uses but does not require DOSLIB.  The other things that are listed as "Required:" on the linked page for sumtextnos.lsp are NOT required (I'll have to fix that some day).

 

It does not ask for a size or place the total as text but that should be pretty easy for you to add to it.  If you load DOSLIB prior to using it then it will copy the total to your clipboard automatically so that it can be pasted wherever you want.

 

The existing code examines the text string for a number, isolates it, converts it from a string into a real and adds it to the sum.  The routine displays the numbers and the total to the text screen.  It could do this for any text string so the routine could be expanded to read MTEXT, ATTIRBUTES, MULTILEADERS, and DIMENSIONS.  There are formatting codes in some of these.  Additional coding to deal with the specific needs for each of these would be necessary.  Also, having more than one numeric value in the string will require code to determine which one or how many to use.  It could get very complicated.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 4 of 11

Ranjit_Singh
Advisor
Advisor
Accepted solution

Like this for example

(defun c:somefunc  (/ d lst etdata ent)
 (while (setq ent (car (nentsel)))
  (and (setq etdata (entget ent)) (setq d (distof (cdr (assoc 1 etdata)))) (setq lst (cons d lst))))
 (if lst
  (entmakex (list '(0 . "MTEXT")
                  '(100 . "AcDbEntity")
                  '(100 . "AcDbMText")
                  (cons 10 (getpoint "\nSelect text insertion point: "))
                  '(40 . 0.2)
                  (cons 1 (rtos (apply '+ lst) 2 2)))))
 (princ))
Message 5 of 11

Anonymous
Not applicable

Hi HENCOOP,

 

The link is not working!!!

 

Can you please post the lisp?\

 

Thank you,

 

Eyal

 

0 Likes
Message 6 of 11

Anonymous
Not applicable

Hi @Ranjit.Singh.

 

Thank you,

 

Thats what I wanted .Although it doesn't works multiline text and tables, it work fine with texts.

 

Can you please add a possibility to enter the height of the insertion text? ( the result text).

and it should be the first question and then the user should click the texts.

 

Thank you.

 

Eyal

 

 

0 Likes
Message 7 of 11

vladimir_michl
Advisor
Advisor

You can try the GrSelNum utility in CAD Studio's freeware library - www.cadstudio.cz/freeware

 

It handles also table cells and nested texts in blocks.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

 

0 Likes
Message 8 of 11

Ranjit_Singh
Advisor
Advisor

I am not sure what you mean. I tested it and it works with mtext and table. Can you explain the problem little bit more.sum_tab_mt_t.gif

0 Likes
Message 9 of 11

vladimir_michl
Advisor
Advisor

and a screencast of GrSelNum:

 

 

 
Message 10 of 11

Anonymous
Not applicable

Hi @Ranjit_Singh,

 

I have tried with another drawing and it works like a charm.

 

maybe I have a problem with one file.

 

Thank you very much, that's what I wanted.

 

Eyal

 

 

0 Likes
Message 11 of 11

Anonymous
Not applicable

Hi @vladimir_michl

 

Thank you,

 

Your solution also works great!

 

Eyal

 

0 Likes