Use Excel functions in AutoCAD fields
Note: This feature is just for AutoField for AutoCAD 2007 or higher.
Exponentiation
X raised to the power of Y = X ^ Y
Logarithm
The LOG function return the base-10 logarithm.
LOG(1000) = 3
Rounds a number to a specified number of digits in AutoCAD field
ROUND(number,num_digits)
- Number is the number you want to round.
- Num_digits specifies the number of digits to which you want to round number.
Remarks
- If num_digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
- If num_digits is 0, then number is rounded to the nearest integer.
- If num_digits is less than 0, then number is rounded to the left of the decimal point.
Examples:
- ROUND(2.15, 1) = 2.2
- ROUND(2.149, 1) = 2.1
- ROUND(-1.475, 2) = -1.48
- ROUND(21.5, -1) = 20
Rounds a number up in AutoCAD field
ROUNDUP(number,num_digits)
- Number is the number you want to round.
- Num_digits specifies the number of digits to which you want to round number.
Remarks
- If num_digits is greater than 0 (zero), then number is rounded up to the specified number of decimal places.
- If num_digits is 0, then number is rounded up to the nearest integer.
- If num_digits is less than 0, then number is rounded up to the left of the decimal point.
Examples:
- ROUNDUP(3.2,0) = 4
- ROUNDUP(76.9,0) = 77
- ROUNDUP(3.14159, 3) = 3.142
- ROUNDUP(-3.14159, 1) = -3.2
- ROUNDUP(31415.92654, -2) = 31500
Rounds a number down in AutoCAD field
ROUNDDOWN(number,num_digits)
- Number is the number you want to round.
- Num_digits specifies the number of digits to which you want to round number.
Remarks
- If num_digits is greater than 0 (zero), then number is rounded down to the specified number of decimal places.
- If num_digits is 0, then number is rounded down to the nearest integer.
- If num_digits is less than 0, then number is rounded down to the left of the decimal point.
Examples:
- ROUNDUP(3.2,0) = 3
- ROUNDUP(76.9,0) = 76
- ROUNDUP(3.14159, 3) = 3.141
- ROUNDUP(-3.14159, 1) = -3.1
- ROUNDUP(31415.92654, -2) = 31400
Conditional statements in AutoCADfield
Conditional statement uses this structure:
IF (<condition>, <result-if-true>, <result-if-false>)
Supported Conditional Operators
- < Less than
- <= Less than or Equal
- > Greater than
- >= Greater than or Equal
- = Equal
- <> NOT Equal
Examples:
- A2 = 50
- IF(A2<=100,"Within budget","Over budget") = Within budget
- IF(A2>89,"A",IF(A2>79,"B", IF(A2>69,"C",IF(A2>59,"D","F")))) = F
- IF(A3>89,"A",IF(A3>79,"B", IF(A3>69,"C",IF(A3>59,"D","F")))) = A
Returns the first character or characters in a text string in AutoCAD field
LEFT(text,num_chars)
- Text is the text string that contains the characters you want to extract.
- Num_chars specifies the number of characters you want LEFT to extract.
Remarks
- Num_chars must be greater than or equal to zero.
- If num_chars is greater than the length of text, LEFT returns all of text.
- Num_chars cannot be omitted.
Examples:
Returns the last character or characters in a text string in AutoCAD field
RIGHT(text,num_chars)
- Text is the text string that contains the characters you want to extract.
- Num_chars specifies the number of characters you want RIGHT to extract.
Remarks
- Num_chars must be greater than or equal to zero.
- If num_chars is greater than the length of text, RIGHT returns all of text.
- Num_chars cannot be omitted.
Examples:
- RIGHT("Sale Price",1) = e
Returns a specific number of characters from a text string in AutoCAD field
MID(text,start_num,num_chars)
- Text is the text string that contains the characters you want to extract.
- Start_num is the position of the first character you want to extract in text. The first character in text has start_num 1, and so on.
- Num_chars specifies the number of characters you want MID to return from text.
Remarks
- If start_num should be greater than 0 and less than the length of text.
- If start_num is less than the length of text, but start_num plus num_chars exceeds the length of text, MID returns the characters up to the end of text.
- num_chars should be positive.
Examples:
- MID("Fluid Flow",1,5) = Fluid
Substitutes new_text for old_text in a text string in AutoCAD field
SUBSTITUTE(text,old_text,new_text)
- Text is the text or the reference to a cell containing text for which you want to substitute characters.
- Old_text is the text you want to replace.
- New_text is the text you want to replace old_text with.
Examples:
- SUBSTITUTE(A2, "Sales", "Cost") = Cost Data
- SUBSTITUTE(A4, "1", "2") = Quarter 2, 2022