cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Creo relations - 'OR' function

SOLVED
Highlighted
Newbie

Creo relations - 'OR' function

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Creo relations - 'OR' function

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

View solution in original post

6 REPLIES 6
Highlighted

Re: Creo relations - 'OR' function

Jonathon,

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

IF C_GEARBOX_CD_DIM == 125|C_GEARBOX_CD_DIM==150

Highlighted

Re: Creo relations - 'OR' function

'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.

Highlighted

Re: Creo relations - 'OR' function

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

View solution in original post

Highlighted

Re: Creo relations - 'OR' function

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?

Highlighted

Re: Creo relations - 'OR' function

Just used this code

IF C_GEARBOX_CD_DIM >= 23.3 & C_GEARBOX_CD_DIM <= 24.7

XD_GEARBOX = 50.8

ELSE

IF C_GEARBOX_CD_DIM >= 30 & C_GEARBOX_CD_DIM <= 32

XD_GEARBOX = 76.2

ENDIF

ENDIF

and so far so good!

Highlighted

Re: Creo relations - 'OR' function

1.) You don't need 'ELSE' if there is nothing after it.

IF C_GEARBOX_CD_DIM >= 601 & C_GEARBOX_CD_DIM <= 900

XD_GEARBOX = 230

ELSE

ENDIF

2.) There is no harm in NOT using ELSE statements. Sometimes it makes reading the code simpler.

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

XD_GEARBOX = 215

ENDIF

IF C_GEARBOX_CD_DIM >= 601 & C_GEARBOX_CD_DIM <= 900

XD_GEARBOX = 230

ENDIF

3.) It's a good idea to preset the controlled parameter/dimension to something that will catch your attention if none of the IF statements are never entered. Right now there is nothing forcing a change to XD_GEARBOX's last value if the checked parameter is outside of the target ranges.

/* Initialize value

XD_GEARBOX = 1

/* Check for valid sizes

IF C_GEARBOX_CD_DIM >= 125 & C_GEARBOX_CD_DIM <= 600

XD_GEARBOX = 215

ENDIF

IF C_GEARBOX_CD_DIM >= 601 & C_GEARBOX_CD_DIM <= 900

XD_GEARBOX = 230

ENDIF

or you could use a nested else statement:

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

ELSE

XD_GEARBOX = 1

ENDIF

ENDIF

Announcements