TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: deep6 on November 07, 2005, 11:22:00 AM

Title: using variable in math function
Post by: deep6 on November 07, 2005, 11:22:00 AM
good morning!
i've been dealing with this for too many days. the short story: i want to take a variable that has been extracted from a block, and use it in a simple expression to get a value for changing the scale of a inserting block.
so, i extract the value from the block attribute, it is 408.908 i assign it the variable 'esta'. now i want to divide it by 50 and assign the answer to the variable 'lval' so it should be as simple as writing this code:
(setq lval'(/ esta 50))

but it does not do the math! i think it has to do with the value of 'esta'  which is correct but when returned at the command line = "408.908". am i right in thinking it is the quotes that are my problem? how do i get rid of them? please help!
-sean




Title: Re: using variable in math function
Post by: MP on November 07, 2005, 11:25:26 AM
Read up on the distof function.
Title: Re: using variable in math function
Post by: David Bethel on November 07, 2005, 11:29:30 AM
Attribute values are always stored as strings.  You will need to convert them to numbers.  Either integer or reals.  ( atof, distof, atoi ) for munber ( angtof ) for angles.

You would need to convert the value back to a string in order to update them block attribute.  -David
Title: Re: using variable in math function
Post by: deep6 on November 07, 2005, 11:42:25 AM
AH! i knew it was staring me in the face!
thanks!
Title: Re: using variable in math function
Post by: Sdoman on November 07, 2005, 03:24:20 PM

(setq lval'(/ esta 50))


In addition, you'll need to remove the quote character that is in front of the division expression in order to evaluate that expression:

(setq lval (/ esta 50) )