Skip to main content
1-Visitor
January 24, 2014
Solved

Creo relations - 'OR' function

  • January 24, 2014
  • 2 replies
  • 14081 views

Hello there.

Is there an 'OR' function or something similar in creo relations (i'm using creo elements/pro)

I have the following string of code, which is what i would like it to look like

IF C_GEARBOX_CD_DIM == 125 OR 150

XD_GEARBOX = 215

ENDIF

this links the user inputted 'CD' and drives the 'XD'

However, there are many figures for 'CD' that would all provide the same 'XD'

I am trying to get around having to write an if statement for each and every 'CD' (there are 72!!)

Is there a function to allow me to have multiple inputs for an 'IF' function, as my attempt above returned an error as 'OR' doesnt exist

Thanks

Jonathan


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
Best answer by TomU

Another option may be to check the range and then check for certain conditions. For example, if the number has to be between 125 and 600, and must be on 25 number increments (125, 150, 175, etc.), you could do the following:

/* Check Range

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

IF FLOOR(C_GEARBOX_CD_DIM / 25) == (C_GEARBOX_CD_DIM / 25)

XD_GEARBOX = 215

ELSE

XD_GEARBOX = 315

ENDIF

ENDIF

2 replies

1-Visitor
January 24, 2014

Jonathon,

You need to separate the staements with "|" ( shift on backspace key)

IF C_GEARBOX_CD_DIM == 125|C_GEARBOX_CD_DIM==150

23-Emerald IV
January 24, 2014

'OR' is the pipe symbol '|'. You have to restate the entire expression though, not just the target values.

IF C_GEARBOX_CD_DIM == 125 | C_GEARBOX_CD_DIM == 150

XD_GEARBOX = 215

ENDIF

You can also use the '\' backslash symbol to continue to multiple lines.

IF C_GEARBOX_CD_DIM == 125 | C_GEARBOX_CD_DIM == 150 | \

C_GEARBOX_CD_DIM == 175 | C_GEARBOX_CD_DIM == 200 | \

C_GEARBOX_CD_DIM == 225 | C_GEARBOX_CD_DIM == 250 | \

C_GEARBOX_CD_DIM == 275 | C_GEARBOX_CD_DIM == 300 | \

C_GEARBOX_CD_DIM == 325 | C_GEARBOX_CD_DIM == 350 | \

C_GEARBOX_CD_DIM == 375 | C_GEARBOX_CD_DIM == 400

XD_GEARBOX = 215

ENDIF

AND is the '&' ampersand.

TomU23-Emerald IVAnswer
23-Emerald IV
January 24, 2014

Another option may be to check the range and then check for certain conditions. For example, if the number has to be between 125 and 600, and must be on 25 number increments (125, 150, 175, etc.), you could do the following:

/* Check Range

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

IF FLOOR(C_GEARBOX_CD_DIM / 25) == (C_GEARBOX_CD_DIM / 25)

XD_GEARBOX = 215

ELSE

XD_GEARBOX = 315

ENDIF

ENDIF

1-Visitor
January 24, 2014

Hi Tom,

Thank you very much for your responses (and Art!)

The CD dimension is from an imperial decimal number.

IE my datasheet has fractioinal inches and it must be converted to decimal inches when entered in the parameters. there is no specific step between the possible entries so would the following work?

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

XD_GEARBOX = 215

ELSE

IF C_GEARBOX_CD_DIM >= 601 & C_GEARBOX_CD_DIM <= 900

XD_GEARBOX = 230

ENDIF

ENDIF

Or perhaps write it like this instead?

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

XD_GEARBOX = 215

ELSE

ENDIF

IF C_GEARBOX_CD_DIM >= 601 & C_GEARBOX_CD_DIM <= 900

XD_GEARBOX = 230

ELSE

ENDIF

As an aside, will creo relations recognise fractions in parameters/

IE if a user inputted 2 7/16 in the parameters, could creo use 2.4375 in its calculations? or is this not possible?