## Conditional formula

For each 3D and 2D parametric design, conditions exist where variables need to have a specific value.

Classic example: Has a part get longer; holes need to be add to maintain a safe distance between them.

#### Logic arguments

Basic principle consists of verifying a condition with the help of arguments. Logic arguments use by Solid Edge:

- Smaller then <
- Equal =
- Larger then >

Once a condition is verify, Solid Edge return a value showing if the condition is valid (true) or non-valid (false).

- For a valid condition (true), the return value is -1
- For a non valid condition (false), the return value is 0

**Note: **All those arguments can be combining to create anoter one like: Equal or larger then ( => )

#### Isolate arguments

Each time we need to verify a condition, isolate it between brackets

- = (Width = Length)
- = (Width < Length)

**Example of a conditional syntax**

Length | Width | Depth |

3.000 | 3.000 | (Length = Width) |

*= (Length = Width) »** Valid condition (-1) »** Return value for the Depth is -1*

#### Absolute value

- To ensure a positive value is return, the use of the mathematical argument «ABS» can be use.

*=ABS (Length = Width) »** Valid condition ABS (-1) »** Return value for the Depth is 1*

- A multiplier argument can also be use:

= -1*(Length = Width) » Valid condition -1*(-1) » Return value fo the **Depth is 1**

From that simple example, it is easy to understand that we need to multiply the return value by the desire quantity.

*Base on this:*

*= -3*(Length = Width) »** Valid condition -3*(-1) »** Return value is 3*

*=ABS (3*(Length = Width)) »** Valid condition ABS(3*(-1)) »** Return value is 3*

#### Logic operators

When more than one conditions need to be validating, it is necessary to use the operators **«AND»** … **«OR». **Notice arguments has been combine to indicate we need to check the length to be «equal or larger then»

*=ABS (3*(Length => 6) and (Length < 12))*

*= -3*(Length => 6) and (Length < 12))*

**Note:**

1. Operator * and + can be use to replace AND…OR, but I recommend keeping those for mathematic operations. This should help make the writing easier and the reading too.

2. It could be more practical to use a control value(s) to help the writing and the reading of the formula.

*https://soliddna.wordpress.com/synchronous_technology/sewst-interface/variables-table/*

*=ABS (3*(Length => Value_min) and (Length < Value_max ))*

In order to help you manipulate and build conditional formula, I resume the process in four steps. Following those steps will help you in the writing of complex formula.

This resume can also be use has a tutorial.

Step 1 – Identify the conditions

Step 2 – Write the condition

Step 3 – Add necessary logic operators

Step 4 – Wrap everything into a single formula

The real problem doesn’t seems to be the “abs” but the “and” and the “or”. I had same trouble and replace my “or” by a + and everything is o.k.

Comment by Nicolas | 24 August 2015 |

Note: This article was written under ST2, the comment made by Steve and the test I made were made under ST5. Make sure you visit

http://www.soliddna.com/SEcommunity/topic/301-comment-on-conditional-formula-by-solidadn/

To have the latest information and update, Thank you

Comment by solidadn | 8 February 2013 |

I find this really useful, BUT if I use for example 281.7 ABS should return 281.7 but solid edge using this formula is rounding it to 282, ABS should return the absolute number. Why is it rounding it of.

Comment by Steve | 5 February 2013 |

Steve,

You may have to check the round-up settings inside SE, on my system, the ABS does not round the value. Here a quick video

Comment by solidadn | 5 February 2013 |

Hi Thanks for the reply, if I use ABS(182.7) then this will return 182.7 as it dose in your video but if you then apply the formula as in the blog which I replied to, ABS((182.7*( Length >=50)and( Length <300))) it returns 183.0.

Oh, and it this formula I find really useful.

Comment by Steve | 6 February 2013 |

Steve let me check this as I can reproduce your situation

Comment by solidadn | 6 February 2013 |

Hi Steve

I think i found the correction to apply to your formula,

Looks like the editor for the comment does not render the text dorrectly.Please see the reply on the copmmunity

http://www.soliddna.com/SEcommunity/topic/301-comment-on-conditional-formula-by-solidadn/Assuming that length is 200, In your formula when we read it, it says

• If Length equal or is larger than 50 report -1…( Length >=50)

• If length is smaller than 300 report -1…( Length =50)and( Length =50)and( Length <300))))

Your formula based on step 2 should have start with

• and = to set the higher limits

In the case you have only two limits

• To set the higher limit

Hope this one is the good one 🙂

Comment by solidadn | 7 February 2013 |