Anda di halaman 1dari 3

MATHEMATICS INSIDE AUTOCAD

AutoCAD provides mathematical functions for working with integers and real
numbers which can be used from within commands when a number is required.

Example:
Command: OFFSET
Offset distance or through<current value>: (/ 1000 4.0)
Select object to offset:
Side to offset?:

Whatever the value of the statement (/ 1000 4.0), it will be supplied at the command
prompt offset distance. This can also be applied to any other command that requires
number data for input.

THE AutoCAD FUNCTIONS

The following are the AutoCAD mathematical functions:

ADDITION (+)
Basic syntax: (+ Number1 Number2 Number3)

If you supply only one number argument, this function returns the result of adding it
to zero; it returns the number. Supplying no arguments returns 0.

Examples:
(+ 1 2) returns 3
(+ 3 -1) returns 2
(+ -1 4.0 returns 3.0
(+ 1 2 3 4.5) returns 10.5
(+ 1 2 3 4.0) returns 10.0

SUBTRACTION (-)
Basic syntax: (- Number1 Number2 )

If you supply more than two number arguments, this function returns the result of
subtracting the sum of the second through last numbers from the first number. If you
supply only one number argument, this function returns the result of subtracting it
from zero; it returns the number. Supplying no argument returns 0.

Examples:
(- 50 40) returns 10
(- 50 40.0) returns 10.0
(- 50 40 2.5) returns 7.5
(- 1.0 -2.5) returns -1.5
(- 2.5 -2.5) returns -5.0
(- 8) returns -8

MULTIPLICATION (*)
Basic syntax: (* Number1 Number2 )

If you supply only one number argument, this function returns the result of
multiplying it by one; it returns the number. Supplying no arguments returns 0.

Examples:
(* 2 3) returns 6
(* 2 3.0) returns 6.0
(* 2 3 4.0) returns 24.0
(* 2 -4.5) returns -13.5
(* 3) returns 3

DIVISION (/)
Basic syntax: (/ Number1 Number2 )

If you supply more than two number arguments, this function divides the first number
by the product of the second through the last numbers, and returns the final quotient.
If you supply only one number argument, this function returns the result of dividing it
to one; it returns the number. Supplying no arguments returns 0.

Example:
(/ 100 2) returns 50
(/ 100 2.0) returns 50.0
(/ 100 20.0 2) returns 2.5
(/ 7 2.0) returns 3.5
(/ 7 2) returns 3
(/ 4) returns 4

EXP
Basic syntax: (exp Number)

Returns the constant e (a real) raised to a specified power (the natural antilog)

Example:
(exp 1.0) returns 2.71828
(exp 2.2) returns 9.02501
(exp -0.4) returns 0.67032

EXPT
Basic syntax: (expt Number Power)

Returns the number raised to a specified power.

Example:
(expt 2 4) returns 16
(expt 3.0 2.0) returns 9.0

NATURAL LOG (LOG)


Basic syntax: (log Number)
Returns the natural log of a number as a real number.

Example:
(log 4.5) returns 1.50408
(log 1.22) returns 0.198851

SQUARE ROOT (SQRT)


Basic syntax: (sqrt Number)

Returns the square root of a number as a real number.

Example:
(sqrt 4) returns 2.0
(sqrt 2.0) returns 1.41421

NOTE:
If all arguments are integers, the value returned is an integer. However, if one or all
arguments are real numbers, the value returned is a real number. To ensure that your
application passes real values, make sure that at least one of the argument is a real
number.

UNIT CONVERSION (CVUNIT)


Basic syntax: (cvunit value from to)

Converts a value from one unit of measurement to another. The value argument is the
numeric value that you want to convert. It can also be a list containing two or more
numbers to convert. The from argument is the unit being converted from, and to is the
unit that the value is being converted into.

Example:
(cvunit 1.0 minute second) returns 60.0
(cvunit 1.0 inch cm) returns 2.54
(cvunit (1.0 2.5) ft in) returns (12.0 30.0)
(cvunit (1 2 3) ft in) returns (12.0 24.0 36.0)
(cvunit 5.0 gallons meter) returns nil

NESTING
There is a technique in solving complex mathematical formula within AutoCAD. It is
called Nesting. It is a process wherein mathematical function (i.e. + - / * expt etc)
can be used in a single line. Examples below:

A+BxC can be written as (* (+ A B) C)


A-B/ C can be written as (/ (- A B) C)
5 + 10 x 2 can be written as (* (+ 5 10) 2) returns 30
5.5 - 2.5 / 2.0 can be written as (/ (- 5.5 2.5) 2.0) returns 1.5

Anda mungkin juga menyukai