Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding values in relations

Status
Not open for further replies.

bruce81

Mechanical
Aug 6, 2008
2
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.
 
Replies continue below

Recommended for you

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.
 
Yes, this is what I was looking for. I knew this was possible but couldn't get my code to work correctly. Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor