Author Topic: using variable in math function  (Read 2188 times)

0 Members and 1 Guest are viewing this topic.

deep6

  • Guest
using variable in math function
« 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





MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: using variable in math function
« Reply #1 on: November 07, 2005, 11:25:26 AM »
Read up on the distof function.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

David Bethel

  • Swamp Rat
  • Posts: 656
Re: using variable in math function
« Reply #2 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
R12 Dos - A2K

deep6

  • Guest
Re: using variable in math function
« Reply #3 on: November 07, 2005, 11:42:25 AM »
AH! i knew it was staring me in the face!
thanks!

Sdoman

  • Guest
Re: using variable in math function
« Reply #4 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) )