Number Multiplication LSP

pokey302
Contributor
Contributor

Number Multiplication LSP

pokey302
Contributor
Contributor
I know that alot of people here are good at making custom LSP files so i was hoping someone could help me out.

Lets say you have a list of all individual numbers on a drawing like so..

22.4
205
7.4
0.6
27
etc.. (notice that some have one decimal place, some don't)

I need to multiply these numbers by a number that I input.

Is there one already made or can someone possibly make a LSP file that will ask for the amount I need my numbers multiplied by, then it will ask for me to start picking the numbers, after i pick one number, that picked number will instantly be multiplied by the number I orignally inputed, and i can keep picking numbers untill i am finished?
0 Likes
Reply
3,016 Views
11 Replies
Replies (11)

Anonymous
Not applicable
See if this will get you what you want.

http://discussion.autodesk.com/thread.jspa?messageID=4926422

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5691901@discussion.autodesk.com...
I know that alot of people here are good at making custom LSP files so i was
hoping someone could help me out.

Lets say you have a list of all individual numbers on a drawing like so..

22.4
205
7.4
0.6
27
etc.. (notice that some have one decimal place, some don't)

I need to multiply these numbers by a number that I input.

Is there one already made or can someone possibly make a LSP file that will
ask for the amount I need my numbers multiplied by, then it will ask for me
to start picking the numbers, after i pick one number, that picked number
will instantly be multiplied by the number I orignally inputed, and i can
keep picking numbers untill i am finished?
0 Likes

pokey302
Contributor
Contributor
Thank you for pointing me to that thread.

That ADDTEXT.LSP is almost exactly what i need.

Is there a way to make it multiply instead of add. And instead of asking for the number of decimal places, make it always use (1) decimal place?
0 Likes

Anonymous
Not applicable
>Is there a way to make it multiply instead of add.
Change any plus symbols (+) to an astrix (*) in the function 'AddStrNReal',
as in this line
(setq txt6 (rtos (+ txt5 RealNum) StrType DecPlace))

>And instead of asking for the number of decimal places, make it always use
>(1) decimal place?
Remove this whole section
(if (not *pec1)
(setq *pec1 3)
)
(setq pec1 (getreal (strcat "\nHow many decimal places [" (itoa *pec1)
"]? ")))
(if pec1
(setq *pec1 (fix pec1))
)

And then here
(PutX ent1 'Textstring (AddStrNReal txt2 txt1 2 *pec1))
change to
(PutX ent1 'Textstring (AddStrNReal txt2 txt1 2 1))


>Thank you for pointing me to that thread.
You're welcome.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5691941@discussion.autodesk.com...
Thank you for pointing me to that thread.

That ADDTEXT.LSP is almost exactly what i need.

Is there a way to make it multiply instead of add. And instead of asking
for the number of decimal places, make it always use (1) decimal place?
0 Likes

Anonymous
Not applicable
ToolPac>Annotation>Numeric>Factor
does what are you looking for
http://www.dotsoft.com/toolpac.htm

wrote in message news:5691901@discussion.autodesk.com...
I know that alot of people here are good at making custom LSP files so i was
hoping someone could help me out.

Lets say you have a list of all individual numbers on a drawing like so..

22.4
205
7.4
0.6
27
etc.. (notice that some have one decimal place, some don't)

I need to multiply these numbers by a number that I input.

Is there one already made or can someone possibly make a LSP file that will
ask for the amount I need my numbers multiplied by, then it will ask for me
to start picking the numbers, after i pick one number, that picked number
will instantly be multiplied by the number I orignally inputed, and i can
keep picking numbers untill i am finished?
0 Likes

pokey302
Contributor
Contributor
T. Willey,

I have tried to slim it down to the following. (i think the ADDTEXT.LSP file added text to numbers so i tried to simplify it)





(defun c:MU (/ txt1 txt2 cnt1 ent1 pec1 ss)
; Add value to text objects

(command "_.undo" "_end")
(command "_.undo" "_group")
(vl-load-com)
(setq txt1 (getreal "\nEnter the value to multiply by. "))
(setq cnt1 0)
(if txt1
(progn
(setq ss (ssget '((0 . "TEXT"))))
(while (/= cnt1 (sslength ss))
(setq ent1 (MakeX (ssname ss cnt1)))
(setq txt2 (GetX ent1 'TextString))
(PutX ent1 'Textstring (AddStrNReal txt2 txt1 2 1))
(setq cnt1 (1+ cnt1))
)
)
)
(prompt "\n May get rounded-off if new decimal is less then existing decimal places!!")
(command "_.undo" "_end")
(princ)
)




This is still adding my number and not multiplying. If i replace the one "+" with an "*" it gives an error. The rounding thing is fixed but the multiplying thing isnt.
0 Likes

Anonymous
Not applicable
>This is still adding my number and not multiplying. If i replace the one
>"+" with an "*" it gives an error. The rounding thing is fixed but the
>multiplying thing isnt.

It looks like I gave you bad advice. You should only need to change this
one line
(setq txt6 (rtos (+ txt5 RealNum) StrType DecPlace))
to
(setq txt6 (rtos (* txt5 RealNum) StrType DecPlace))
so that it will multiply instead of adding.

Sorry about that.
--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5691947@discussion.autodesk.com...
T. Willey,

I have tried to slim it down to the following. (i think the ADDTEXT.LSP
file added text to numbers so i tried to simplify it)





(defun c:MU (/ txt1 txt2 cnt1 ent1 pec1 ss)
; Add value to text objects

(command "_.undo" "_end")
(command "_.undo" "_group")
(vl-load-com)
(setq txt1 (getreal "\nEnter the value to multiply by. "))
(setq cnt1 0)
(if txt1
(progn
(setq ss (ssget '((0 . "TEXT"))))
(while (/= cnt1 (sslength ss))
(setq ent1 (MakeX (ssname ss cnt1)))
(setq txt2 (GetX ent1 'TextString))
(PutX ent1 'Textstring (AddStrNReal txt2 txt1 2 1))
(setq cnt1 (1+ cnt1))
)
)
)
(prompt "\n May get rounded-off if new decimal is less then existing
decimal places!!")
(command "_.undo" "_end")
(princ)
)




This is still adding my number and not multiplying. If i replace the one
"+" with an "*" it gives an error. The rounding thing is fixed but the
multiplying thing isnt.
0 Likes

pokey302
Contributor
Contributor
apparently my narrowing down didnt work. But i was able to get it to multiply and remove the rounding option.

THANK YOU SO MUCH FOR THE HELP!


You would'nt by chance know what lines to remove so it will stop asking to put commas in numbers greater than 1000? (we do not use commas).
0 Likes

Anonymous
Not applicable
You're welcome.

Change this line
(setq op1 (getkword "\nWould you like to add comma(s) [Y,]? "))
to
(setq op1 "Y") if you want the comma
or to
(setq op1 "N") if you don't want the comma.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5692045@discussion.autodesk.com...
apparently my narrowing down didnt work. But i was able to get it to
multiply and remove the rounding option.

THANK YOU SO MUCH FOR THE HELP!


You would'nt by chance know what lines to remove so it will stop asking to
put commas in numbers greater than 1000? (we do not use commas).
0 Likes

pokey302
Contributor
Contributor
Thank you SO much!!
0 Likes

Anonymous
Not applicable

Hi I realize that I am replying to an old post here, but I wasn't able to locate the referenced discussion (http://discussion.autodesk.com/thread.jspa?messageID=4926422). Let me know if you can help! Thank you!

0 Likes

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... I wasn't able to locate the referenced discussion ....


If you put something distinctive in the subsequent suggested modifications into the Search window, maybe something that it finds will be the source.  Try AddStrNReal.

Kent Cooper, AIA
0 Likes