×
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

Rounding values in relations

Rounding values in relations

Rounding values in relations

(OP)
I am trying to round a parameter up to either 5 or 10.  I am wondering if there is a way to write this into the relations so when this parameter is calculated in the relations it rounds automatically.

RE: Rounding values in relations

I'm assuming that you want to round to the nearest multiple of 5.
Pro/E doesn't have a 'modulo' function in its relations editor, so its necessary to brew your own. It's messy either way.

Let's say your parameter is called "NUM". Relation code for rounding it is as follows:

CODE

TEMP1 = NUM/5
TEMP2 = floor(TEMP1)   
TEMP3 = TEMP1-TEMP2

IF TEMP3 < 0.5     
ROUNDED_NUM = 5*TEMP2
ELSE
ROUNDED_NUM = 5*TEMP2+5
ENDIF

There's probably more efficient ways to do this, though, but it's a solution that has worked well for me in the past.
 

RE: Rounding values in relations

(OP)
Yes, this is what I was looking for.  I knew this was possible but couldn't get my code to work correctly. Thank you

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