×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Expression help

Expression help

Expression help

(OP)
Hi,

I have model with an expression controlling the length. I have one row of holes and want the number of holes in the x axis to vary depending on the length. For example if length is over 100mm then I want two holes, if length is over 200mm then I want three holes.

Below is the expression I have used

if(length>100)(2)else(if(length>200)(3)else(if(length>300)(4)else(1)))

Any ideas where I am going wrong? Any help VERY much appreciated.

Mark Noyce

Mark Noyce
Senior Design Engineer/CAD co-ordinator

RE: Expression help

Try this instead.


if(length<100)(1)else(if(length<200)(2)else(if(length<300)(3)else(4)))

your original expression would only output 1 or 2.  As soon as the value of length was over 100 it would not get any further down the chain if if statements as 200 is still greater than 100 therfore the result is still 2.
Hope that makes sense.

You'll have to make your positioning of your first hole and the array spacing a function of the output of this expression to ge the holes equispaced.

Cheers,

Mark Benson
Aerodynamic Model Designer

RE: Expression help

try

if (legth>100)(2) else if(length>200)(3) else if(length>300)(4)else(1)

that should be all clown

RE: Expression help

(OP)
Excellent! Thank you MSPBenson, that worked a treat!

Vitulaaak, I tried yours too but it didn't seem to work :(

Mark Noyce
Senior Design Engineer/CAD co-ordinator

RE: Expression help

well,funny..i tried it again and
if(cond>20)(10) else if (cond<20)(20)else(15)

worked fine...

RE: Expression help

vitulaak,
your first expression can not work, because if the length is say 350, which is > 100 (your first condition) then it inserts 2 holes and does not go farther - the condition (>100) was satisfied).
Your second expression is different - you should see (15) only if the cond=20, because the first two parts (>20, <20) cover all remaining (real) numbers.

RE: Expression help

well, i just meant the syntax...if you have descending order 300.200.100, then it works and you dont have to use the number of brackets

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources