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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Relations (Else If) in Repeat Region

Ketan_Lalcheta
19-Tanzanite

Relations (Else If) in Repeat Region

Hello,

I am able to set relations in repeat region as below:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

I would like to understand how to use else if into relation. My scenario is as below:

  • CAD_SAP_PLM_IDX = "1000" for "PRT0001"
  • CAD_SAP_PLM_IDX = "1001" for "PRT0002"
  • CAD_SAP_PLM_IDX = rpt.index for rest all parts

Thank you in advance.

Regards

Ketan


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.
ACCEPTED SOLUTION

Accepted Solutions
Dale_Rosema
23-Emerald III
(To:James62)

Remember that for every "if" you need and an "endif" at the end.

I have a word doc that I can cut and paste as needed (a sample of that file):

IF asm_mbr_pn == "9594"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9556"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9151"

NEWQTY = "0.5"

ELSE

ENDIF

ENDIF

ENDIF

View solution in original post

5 REPLIES 5

By stacking up all the ifs. Each if statement has to end with an endif.

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

else

if asm_mbr_name == "PRT0003"

CAD_SAP_PLM_IDX = "1002"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

endif

endif

Dale_Rosema
23-Emerald III
(To:James62)

Remember that for every "if" you need and an "endif" at the end.

I have a word doc that I can cut and paste as needed (a sample of that file):

IF asm_mbr_pn == "9594"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9556"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9151"

NEWQTY = "0.5"

ELSE

ENDIF

ENDIF

ENDIF

JLG
12-Amethyst
12-Amethyst
(To:James62)

For those of us who have trouble keeping track of our if statements, it's really helpful to indent the statements:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

else

if asm_mbr_name == "PRT0003"

CAD_SAP_PLM_IDX = "1002"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

endif

endif

Then it's easy to see if you're missing an "endif", and which "else" goes with which "if". Just remember that Creo doesn't care about whitespace (spaces and tabs), so if you were to write:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

endif

Creo thinks the "endif" goes with the last "if", not the first "if". When things go wrong in a nested if statement, it's often because we get confused about where we are when writing the statements. Indenting the code helps to get your thinking straight.

TomU
23-Emerald IV
(To:Ketan_Lalcheta)

To summarize, there is no built in "ELSE IF" in Creo. You can get the same effect by using "ELSE", then another "IF", then another "ELSE" and so on, but deeply nested "IF" and "ELSE" statements can get tough to follow.

For repeat region relations I prefer to set the default value and then check for the other conditions. (The last one set "wins".)

CAD_SAP_PLM_IDX = RPT_INDEX

IF ASM_MBR_NAME == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

ENDIF

IF ASM_MBR_NAME == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

ENDIF

Ketan_Lalcheta
19-Tanzanite
(To:TomU)

Thank you all for help.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags