Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Number Multiplication LSP

11 REPLIES 11
Reply
Message 1 of 12
pokey302
2972 Views, 11 Replies

Number Multiplication LSP

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?
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: pokey302

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?
Message 3 of 12
pokey302
in reply to: pokey302

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?
Message 4 of 12
Anonymous
in reply to: pokey302

>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?
Message 5 of 12
Anonymous
in reply to: pokey302

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?
Message 6 of 12
pokey302
in reply to: pokey302

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.
Message 7 of 12
Anonymous
in reply to: pokey302

>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.
Message 8 of 12
pokey302
in reply to: pokey302

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).
Message 9 of 12
Anonymous
in reply to: pokey302

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).
Message 10 of 12
pokey302
in reply to: pokey302

Thank you SO much!!
Message 11 of 12
Anonymous
in reply to: Anonymous

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!

Message 12 of 12
Kent1Cooper
in reply to: Anonymous


@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report