Expression Builder Syntax

Expression Builder Syntax

Anonymous
Not applicable
2,502 Views
9 Replies
Message 1 of 10

Expression Builder Syntax

Anonymous
Not applicable

I'm not a programmer, but I would like to create formulas in the BOM using the Expression Builder. However, I cannot find any documentation that explains the syntax of each function (Ex: ABS, ACOS, AND, etc.). Can anyone tell me where to find this? It is not in AutoCAD help menu and Google was not much help.

0 Likes
Accepted solutions (1)
2,503 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

I'd like to know how to do this too, so I'm going to piggyback on this post.

0 Likes
Message 3 of 10

Anonymous
Not applicable
Accepted solution

To all:

The solution is actually buried in the Help menu.

Go to User's Guide/Create and Use Formulas/About Formulas. Then scroll down and find 'Commands'. Hit the + button to expand this (see below).

Capture.JPG

 

Keep scrolling down until you find the functions separated by the following categories: Numerical Functions, Logical Functions, and Text Functions. All of the functions in 'Expression Builder' are explained here.

 

 

NUMERICAL FUNCTIONS

ABS(x)

Returns the absolute value of x.

ACOS(x)

Returns the arccosine (inverse cosine) of x, in radians.

ASIN(x)

Returns the arcsine (inverse sine) of x, in radians.

ATAN(x)

Returns the arctangent (inverse tangent) of x, in radians.

COS(x)

Returns the cosine value of x, where x is an angle measured in radians.

EXP(x)

Returns e raised to the power of x. The constant e is taken as 2.718282

CEILING(x, number_of_decimal_places)

Rounds up x to the specified number of decimal places. For example, CEILING(8.546, 1) is equal to 8.6.

FLOOR (x, number_of_decimal_places)

Rounds down x to the specified number of decimal places. For example, FLOOR(8.546, 1) is equal to 8.5.

INT(x)

Rounds down x to the integer. For example, INT(2.97) is equal to 2. For negative values, x the return value is zero.

LN(x)

Returns the natural logarithm of x.

MAX(x1, x2,...)

Returns the biggest number. The function can take up to 20 arguments.

MIN( x1, x2,...)

Returns the smallest number. The function can take up to 20 arguments.

MOD(x1, x2)

Returns the remainder of the integer division x1/x2. Both arguments must be integers.

PI()

Returns the value of the constant PI (3.141592653589....)

SIN(x)

Returns the sine value of x, where x is an angle measured in radians.

SQRT(x)

Returns the square root of x.

TAN(x)

Returns the tangent value of x, where x is an angle measured in radians.

TEXT(x, format)

Converts x to a text, formatted with leading zeros and decimal places as specified in format argument. The format argument is a text like “0.00” or “000.00”, and so on. For example, TEXT(5.1246,”000.00”) evaluates to “005.12”.

DIMSTYLEANG(x, style)

Converts x to the angular data format. The style value is a valid dimstyle name existing in the current drawing. The text is formatted by using the dimstyle setting. The result text can contain other MTEXT formatting sequences (color, font, text size).

DIMSTYLELIN(x, style)

Converts x to a linear value. The style value is a valid dimstyle name existing in the current drawing.

 

 

LOGICAL FUNCTIONS

AND(logical_expression1, logical_expression2,...)

Returns FALSE if at least one of the arguments is FALSE. Otherwise returns TRUE.

OR(logical_expression1, logical_expression2,...)

Returns TRUE if at least one of the arguments is TRUE. Otherwise returns FALSE.

NOT(logical_expression)

Returns negation of the logical_expression argument.

CHOOSE(index,value1,value2,...)

Returns value corresponding to the index. Index must be an integer value.

FALSE()

Returns logical FALSE value.

IF(logical_expression,value_true, value_false)

Returns value_true, when the result of the logical_expression is TRUE, or value_false when the result of the logical_expression is FALSE.

ISBLANK(x)

Returns TRUE if x contains only invisible characters or spaces.

TRUE()

Returns logical TRUE value.

GT(x1,x2)

Returns TRUE if x1 is greater than x2. Otherwise returns FALSE.

GTE(x1,x2)

Returns TRUE if x1 is equal to or greater than x2 . Otherwise returns FALSE.

EQUAL(x1,x2)

Returns TRUE if x1 is equal to x2. Otherwise returns FALSE.

LTE(x1,x2)

Returns TRUE if x1 is equal to or less than x2. Otherwise returns FALSE.

LT(x1,x2)

Returns TRUE if x1 is less than x2 . Otherwise returns FALSE.

 

 TEXT FUNCTIONS

FIND(find_text, within_text, start_index)

Locates the argument find_text in the argument within_text and returns the starting position of find_text in within_text. The start_index argument specifies the character at which the search starts. If find_text is not found, the function returns -1.

LEFT(text, num_chars)

Returns the first num_chars characters of the argument text.

MID( text, start_at, num_chars)

Returns num_chars characters from the argument text, starting from the position start_at.

RIGHT( text, num_chars)

Returns the last num_chars characters of the argument text.

LEN(text)

Returns the number of characters (length) of the argument text.

LOWER(text)

Returns the argument text, converted completely to lower case.

UPPER(text)

Returns the argument text, converted completely to upper case letters.

REPLACE(original_text,start_position,num_chars,inserted_string)

Returns a text string created by way of replacing num_chars characters in original_text, with inserted_string, starting at start_postion.

TRIM(text)

Returns a text string with all leading and trailing spaces from the argument text removed.

 

 

 

Message 4 of 10

Anonymous
Not applicable

For the LOGICAL formula, are the arguments both numeric and strings?

I mean, Does EQUAL(X1,X2) function work with strings? I've tried, but result is Always true ... Example: EQUAL("KG","MT") returns True.

 

TY

0 Likes
Message 5 of 10

Anonymous
Not applicable

I've tried and failed at comparing text strings as well. The most recent help literature says something about enclosing all text formulas in angle brackets <>, but that didn't work for me either. Hopefully one of the AutoCAD Mechanical experts can weigh in on this.

Message 6 of 10

cheryl.buck
Autodesk Support
Autodesk Support

Greetings @Anonymous,

 

Great question! As far as I understand it, logical functions need to be numeric (or arithmetic) because the function must be able to make a comparison between the values.  Under those conditions, text strings will not work. I found this AKN (Autodesk Knowledge Network) article on Logical Functions in AutoCAD Mechanical. I hope it is helpful. 

  

Please select the Accept as Solution button if my post solves your issue or answers your question.

Cheryl Buck
Technical Support Specialist



Did a post answer your question or help resolve the issue? Please click the Accept Solution button.
If you find a response helpful, consider Liking the post.

0 Likes
Message 7 of 10

Anonymous
Not applicable

Hi Thank You,

yes, I knew that article, and it wasn't clear whether the arguments should be numeric or strings. Now it's clear.

But, is it not possible to compare two strings with formulas or any other way? My goal is to compare two strings and make a decisione if equals or not.

 

Thank you in advance.

Message 8 of 10

cheryl.buck
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

I don't know of an AutoCAD logical function that can compare 2 text strings and return a true false. Here are the available Text Functions | AutoCAD Mechanical.

 

This may be the article @Anonymous mentioned: About Formulas.

 

This article on equal (AutoLISP) specifically mentions it can handle strings so there may be a way to accomplish it that way. Another method could be to do the comparison in Excel using the EXACT function and import the data table depending on how you are using the data. 

 

It would be great if you could come back and let us all know if either method works for you. 

Cheryl Buck
Technical Support Specialist



Did a post answer your question or help resolve the issue? Please click the Accept Solution button.
If you find a response helpful, consider Liking the post.

Message 9 of 10

Anonymous
Not applicable

Lisp ok to compare Strings.

TY

0 Likes
Message 10 of 10

cheryl.buck
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

You are quite welcome! Have fun!

Cheryl Buck
Technical Support Specialist



Did a post answer your question or help resolve the issue? Please click the Accept Solution button.
If you find a response helpful, consider Liking the post.

0 Likes