View Full Version : Sum of numbers in text strings
mikman
12th Aug 2008, 07:30 pm
I was recently using a lisp that added up text and created a text string with the sum. It stopped working and quoted the function "mktext" as the problem. It will still add the strings but it will not create a new string. I can't modify the routine, its locked and the owner doesn't work with me anymore. :( /:D Where can I find a place that would have a lisp that I could read and learn for myself?
fixo
12th Aug 2008, 07:43 pm
Hi Mike
Take a look at this page,
I think it's the best one you could be
able to find on the web:
http://afralisp.net/
FYI, I've started to learn lisp and VBA from there
~'J'~
fixo
12th Aug 2008, 08:06 pm
Here is a quick example, hope this helps
(defun C:STX (/ elist en ss sum sumtxt txt)
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
2
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; display message :
(alert (strcat "\nSumm = " sumtxt))
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
Sorry for my poor english :)
~'J'~
mikman
12th Aug 2008, 08:21 pm
(alert (strcat "\nSumm = " sumtxt))
That works pretty good Fixo. At this point where the window pops up with the number, do you know how to make a new text string? You are miles ahead of me so I hope you can help?
fixo
12th Aug 2008, 08:53 pm
You are miles ahead of me so I hope you can help?
Do not agreed with you
The Earth is so small, take a look on map -
just 5-6 thousand of miles or so :)
Here is edited version
This will create the new text entity with
the same properties as the first selected
text has
(defun C:STX (/ cpent elist en ip newtxt pt ss sum sumtxt txt)
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; store the first text entity for using 'em further :
(setq cpent (ssname ss 0))
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
2
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; display message in the command line:
(princ (strcat "\nSumm=" sumtxt))
(setq pt (getpoint "\nSpecify the new text location: "))
;; get the insertion point of stored entity :
(setq ip (cdr (assoc 10 (entget cpent))))
;; copy text entity to the new destination point :
(command "_copy" cpent "" ip pt)
;; get the last created entity :
(setq newtxt (entlast))
;; get entity list of them :
(setq elist (entget newtxt))
;; modify entity list with new text string :
(entmod (subst (cons 1 sumtxt)(assoc 1 elist) elist))
;; update changes :
(entupd newtxt)
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
~'J'~
mikman
12th Aug 2008, 10:01 pm
:D Fixo that worked great. I learned some new things and what you wrote was exactly what I needed. Thanks heaps!:D
fixo
12th Aug 2008, 10:11 pm
You are welcome
Happy computing,
Cheers :)
~'J'~
sanalmakina
6th Aug 2010, 12:51 pm
hi!
i'm using this lisp but if it's possible i want an addition.
i want to sum texts with unit. for example:
i will select: 1, 2, and 3
it sums and creates a text which is: 6 m³/h or 6 Watt etc.
how can i do this?
Here is a quick example, hope this helps
(defun C:STX (/ elist en ss sum sumtxt txt)
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
2
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; display message :
(alert (strcat "\nSumm = " sumtxt))
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
Sorry for my poor english :)
~'J'~
Lt Dan's legs
6th Aug 2010, 03:39 pm
Look near the end of the code for
;; display message :
and replace the line below with
(setq ins (getpoint "\nSpecify text location: "))
(entmake (list (cons 0 "text")
(cons 1 (strcat sumtxt "m3/h"));;text
(cons 7 "ROMANS");;text style
(cons 8 "acc");;textlayer
(cons 10 ins);;insertion point
(cons 11 ins)
(cons 40 2);;text height
(cons 62 256);;bylayer
(cons 72 1);;horizontal justification
)
)
and replace
;; 2 is for metric units (3 for engineering) :
2
with 5
by the way great routine fixo!
Why not put your name on it fixo?
sanalmakina
6th Aug 2010, 04:05 pm
i'm sorry i couldn't make it. i changed the (setq ins ... code with your code but, it did not work. Could you add the whole code please? I will really appreciate it.
-i saw your changed message after my post sorry.
-yes i didn't want to see decimal part, so i changed "2" with so many numbers and catch the 5 (by luck) :D
-sorry for my poor English.
Lt Dan's legs
6th Aug 2010, 04:16 pm
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(entmake (list '(0 . "text")
(cons 100 "AcDbEntity")
(cons 100 "AcDbText")
(cons 1 (strcat sumtxt "m3/h"));;text
(cons 7 "ROMANS");;text style
(cons 8 "acc");;textlayer
(cons 10 ins);;insertion point
(cons 11 ins)
(cons 40 2);;text height
(cons 41 1);;text width
(cons 50 0);;text rotation
(cons 62 256);;bylayer
(cons 72 0);;horizontal justification
)
);;end revision by Reid B.
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
sanalmakina
6th Aug 2010, 04:29 pm
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(entmake (list (cons 0 "text")
(cons 1 (strcat sumtxt "m3/h"));;text
(cons 7 "ROMANS");;text style
(cons 8 "acc");;textlayer
(cons 10 ins);;insertion point
(cons 11 ins)
(cons 40 2);;text height
(cons 41 1);;text width
(cons 50 0);;text rotation
(cons 62 256);;bylayer
(cons 72 0);;horizontal justification
)
);;end revision by Reid B.
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
Thank you Lt Dan's legs but, it doesn't work for me :s when i clicked for insertation, nothing happened.
Lt Dan's legs
6th Aug 2010, 04:34 pm
code above revised
Let me know if that solves the problem
David Bethel
6th Aug 2010, 04:47 pm
if I understand the OP correctly, you can simplify the deal:
;;;Given a true numeric string list
(setq s1 "3.4 5.6 7 8. 9")
;;;Format the string into an autolisp funtion
(setq as (strcat "(+ " s1 ")"))
;;;Evaluate the string
(setq av (eval (read as)))
;;;Contevrt the results into a string
(setq ar (rtos av))
;;;Print the results
(princ ar)
-David
Tharwat
6th Aug 2010, 05:00 pm
I think he means the following adds to meet his desire...
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec"))" " "m3/h")
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(command "_.text" ins "" "" sumtxt)
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
sanalmakina
6th Aug 2010, 05:18 pm
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(entmake (list '(0 . "text")
(cons 100 "AcDbEntity")
(cons 100 "AcDbText")
(cons 1 (strcat sumtxt "m3/h"));;text
(cons 7 "ROMANS");;text style
(cons 8 "acc");;textlayer
(cons 10 ins);;insertion point
(cons 11 ins)
(cons 40 2);;text height
(cons 41 1);;text width
(cons 50 0);;text rotation
(cons 62 256);;bylayer
(cons 72 0);;horizontal justification
)
);;end revision by Reid B.
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
i tried but it didn't work :(. command text:
Command: appload
asd.lsp successfully loaded.
asd.lsp successfully loaded.
Command:
Start command with STX...
Command:
Start command with STX...
Command:
Command: text
Current text style: "K2000Style" Text height: 0.1000 Annotative: No
Specify start point of text or [Justify/Style]:
Specify rotation angle of text <0>: <Ortho on>
Command: Specify opposite corner:
Command: c COPY 1 found
Current settings: Copy mode = Multiple
Specify base point or [Displacement/mOde] <Displacement>: Specify second point
or <use first point as displacement>:
Specify second point or [Exit/Undo] <Exit>: *Cancel*
Command: stx
>>> Select text to get summ >>>
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects:
Specify text location:
I think he means the following adds to meet his desire...
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec"))" " "m3/h")
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(command "_.text" ins "" "" sumtxt)
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
it writes it to command bar, not to the drawing:(.
command text:
Current text style: "K2000Style" Text height: 0.1000 Annotative: No
Specify start point of text or [Justify/Style]:
Specify rotation angle of text <0>: <Ortho on>
Command:
Command: c COPY 1 found
Current settings: Copy mode = Multiple
Specify base point or [Displacement/mOde] <Displacement>: Specify second point
or <use first point as displacement>:
Specify second point or [Exit/Undo] <Exit>: *Cancel*
Command: stx
>>> Select text to get summ >>>
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects:
Specify text location: _.text
Current text style: "K2000Style" Text height: 0.1000 Annotative: No
Specify start point of text or [Justify/Style]:
Specify rotation angle of text <0>:
Enter text:
Command: 246246 m3/h Unknown command "246246 M3/H". Press F1 for help.
Command:
alanjt
6th Aug 2010, 05:28 pm
(cons 7 "ROMANS");;text style
You are relying on this textstyle actually existing.
Replace with
(cons 7 (getvar 'textstyle))
Tharwat
6th Aug 2010, 05:29 pm
The problem is with the Text Style which is current , I mean put the Text height for it zero and try again.
alanjt
6th Aug 2010, 05:30 pm
The problem is with the Text Style which is current , I mean put the Text height for it zero and try again.No, use entmake. Text in command is the most temperamental function that can be called.
Lt Dan's legs
6th Aug 2010, 05:35 pm
(cons 7 (getvar 'textstyle))
thank you Alan! I'll definitely use this one
Tharwat
6th Aug 2010, 05:37 pm
No, use entmake. Text in command is the most temperamental function that can be called.
That's right,
Here it goes with enmake ......
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec"))" " "m3/h")
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(entmake (list '(0 . "TEXT")
(cons 40 (getvar 'textsize))
(cons 10 ins)
(cons 1 sumtxt)
)))
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
alanjt
6th Aug 2010, 05:39 pm
(cons 7 (getvar 'textstyle))thank you Alan! I'll definitely use this one
Actually, it was textsize I was thinking about. Entmake will use the current textstyle to create the text, you don't need it at all, unless you want a different style. Sorry about that.
Lt Dan's legs
6th Aug 2010, 05:43 pm
Actually, it was textsize I was thinking about.
this is something that is useful to me.
So, is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed?
Tharwat
6th Aug 2010, 05:44 pm
YES. things like my previous reply. :)
The problem is with the Text Style which is current , I mean put the Text height for it zero and try again.
alanjt
6th Aug 2010, 05:45 pm
this is something that is useful to me. So, is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed?
It varies with certain objects.
Lt Dan's legs
6th Aug 2010, 05:48 pm
what about in this case? I wasn't sure if the version of acad played a factor
sanalmakina
6th Aug 2010, 05:49 pm
That's right,
Here it goes with enmake ......
(defun C:STX (/ elist en ss sum sumtxt txt ins)
;;created by Fixo
;;revised by Reid B. for sanalmakina
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
5;;revised by Reid B.
;; set precision by current :
(getvar "dimdec"))" " "m3/h")
)
;; delete entity from selection set :
(ssdel en ss)
)
;; Change to text :
(setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B.
(entmake (list '(0 . "TEXT")
(cons 40 (getvar 'textsize))
(cons 10 ins)
(cons 1 sumtxt)
)))
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
Thank you so much , it worked! :)
-fixo
-Lt Dan's legs
-David Bethel
-tharwat313
-alanjt
alanjt
6th Aug 2010, 05:50 pm
what about in this case? I wasn't sure if the version of acad played a factorVersion shouldn't have a factor, but don't quote me on that.
Lt Dan's legs
6th Aug 2010, 05:56 pm
don't quote me on that.
:P
I've come across this before but I didn't understand why it was used.. maybe I'll search for that routine and have another look at it.
Thanks
Tharwat
6th Aug 2010, 05:57 pm
Thank you so much , it worked! :)
-fixo
-Lt Dan's legs
-David Bethel
-tharwat313
-alanjt
First we should thank Mr.fixo because the codes were written by him.
I am glad you got it worked finally.. :)
Enjoy it ..
Tharwat
Lee Mac
6th Aug 2010, 07:31 pm
So, is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed?
For legacy reasons, entmake ignores DXF group code 100 data for the following entity types:
AcDbText
AcDbAttribute
AcDbAttributeDefinition
AcDbBlockBegin
AcDbBlockEnd
AcDbSequenceEnd
AcDbBlockReference
AcDbMInsertBlock
AcDb2dVertex
AcDb3dPolylineVertex
AcDbPolygonMeshVertex
AcDbPolyFaceMeshVertex
AcDbFaceRecord
AcDb2dPolyline
AcDb3dPolyline
AcDbArc
AcDbCircle
AcDbLine
AcDbPoint
AcDbFace
AcDbPolyFaceMesh
AcDbPolygonMesh
AcDbTrace
AcDbSolid
AcDbShape
AcDbViewport
It is required in all other entities.
Lt Dan's legs
6th Aug 2010, 07:42 pm
Would you say it's good practice to include or should I get familiar with this?
Lee Mac
6th Aug 2010, 07:44 pm
Would you say it's good practice to include or should I get familiar with this?
Its no harm to include them, but it will fail if those code are not included when needed.
I usually only include the codes that are needed, but then I usually can't be bothered to type it out lol
Lt Dan's legs
6th Aug 2010, 07:49 pm
Looking at the list all the things is use entmake for are there... but I am pretty forgetful. I think I'll include in my routines so I don't forget when it matters and wonder why it's not working. Thanks
Lee Mac
6th Aug 2010, 07:57 pm
There aren't too many entities that need it, but most commonly I find MText and LWPolylines.
sandman007
9th Dec 2010, 06:58 pm
Hey I just started to use this lisp... That Fixo wrote and others edited from this thread...
The problem I'm having is all out text is underlined for our key notes. and the lisp will not add them up.
here's the code. is there anyone that can fix it so it recognizes the underlined text strings.
(defun C:STX (/ cpent elist en ip newtxt pt ss sum sumtxt txt)
(princ "\n\t\t>>> Select text to get summ >>>")
(if
;;select texts/mtexts on screen :
(setq ss (ssget '((0 . "*TEXT"))))
;; if selected then :
(progn
;; store the first text entity for using 'em further :
(setq cpent (ssname ss 0))
;; set initial sum to zero :
(setq sum 0.)
;; loop trough selected texts/mtexts :
(while
;; get the first text in selection :
(setq en (ssname ss 0))
;; get entity list of them :
(setq elist (entget en))
;; get the textstring by key 1 from entity list :
(setq txt (cdr (assoc 1 elist)))
;; create output string :
(setq sumtxt
;; concatenate strings :
(strcat
;; convert digits to string :
(rtos
;; add to summ the digital value of text :
(setq sum (+ (atof txt) sum))
;; 2 is for metric units (3 for engineering) :
2
;; set precision by current :
(getvar "dimdec")))
)
;; delete entity from selection set :
(ssdel en ss)
)
;; display message in the command line:
(princ (strcat "\nSumm=" sumtxt))
(setq pt (getpoint "\nSpecify the new text location: "))
;; get the insertion point of stored entity :
(setq ip (cdr (assoc 10 (entget cpent))))
;; copy text entity to the new destination point :
(command "_copy" cpent "" ip pt)
;; get the last created entity :
(setq newtxt (entlast))
;; get entity list of them :
(setq elist (entget newtxt))
;; modify entity list with new text string :
(entmod (subst (cons 1 sumtxt)(assoc 1 elist) elist))
;; update changes :
(entupd newtxt)
)
)
(princ)
)
(princ "\nStart command with STX...")
(princ)
alanjt
9th Dec 2010, 07:12 pm
http://www.cadtutor.net/forum/showthread.php?46688-Combinevalues.LSP-Add-Divide-Multiply-Subtract-object-values
sandman007
9th Dec 2010, 07:53 pm
http://www.cadtutor.net/forum/showthread.php?46688-Combinevalues.LSP-Add-Divide-Multiply-Subtract-object-values
Awesome! How is the text height controlled?
Lt Dan's legs
9th Dec 2010, 08:01 pm
Assuming Alan used (getvar 'textsize)
if you want to have 4" high text then
(setvar 'textsize 4)
__edit__
actually I do not see it...
alanjt
9th Dec 2010, 08:41 pm
Assuming Alan used (getvar 'textsize)
if you want to have 4" high text then
(setvar 'textsize 4)
__edit__
actually I do not see it...
vla-AddMText uses the current text settings (style and textsize variable). I use it over entmake because it works with annotative text styles.
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.