Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Relations parameters

Status
Not open for further replies.

Daniel Tomas

Mechanical
Dec 5, 2023
2
Hello everybody,
I need help building relationship parameters for a Creo prototype.
I have the following code:

comp_val1=0
comp_val2=0
comp_val3=0
EPOST = NO
EPOST_INTERM = NO
NUM_INT=0
VPOST="0"


IF extract(rel_model_name,1,2)=='IM'
MOLDE_N=extract(rel_model_name, 1,search(rel_model_name,"_")-1)
NUM=extract(rel_model_name,search(rel_model_name,"_")+1,string_length(rel_model_name)-search(rel_model_name,"_"))
IF string_length(NUM)>2
IF search(NUM,"_")!=0
VPOST=extract(NUM, search(NUM,"_"),(string_length(NUM)-search(NUM,"_")+1))
IF search(VPOST,"_")!=0 & search(VPOST,"-")==0
EPOST= YES
ELSE
EPOST_INTERM = YES
ENDIF
ENDIF
ENDIF
ELSE

IF search(rel_model_name,"--")>0
NUM=extract(rel_model_name,1,search(rel_model_name,"--")-1)
ENDIF
IF search(rel_model_name,"_")==4
TEMP_NUM=extract(rel_model_name,1,3)
ELSE
IF search(rel_model_name,"_")==3
TEMP_NUM=extract(rel_model_name,1,2)
ELSE
TEMP_NUM=extract(rel_model_name,1,1)
ENDIF
ENDIF
ENDIF

IF search(NUM,"_") == 0 & search(NUM,"-") == 0
TEMP_NUM=extract(NUM,1,string_length(NUM))
ENDIF
IF search(NUM,"_") != 0 & search(NUM,"-") == 0
TEMP_NUM=extract(NUM,1,search(NUM,"_")-1)
ENDIF
IF search(NUM,"_") == 0 & search(NUM,"-") != 0
TEMP_NUM=extract(NUM,1,search(NUM,"-")-1)
ENDIF
IF search(NUM,"_") != 0 & search(NUM,"-") != 0
TEMP_NUM=extract(NUM,1,search(NUM,"-")-1)
ENDIF

IF string_length(temp_num)>=1
comp_num1=extract(temp_num,1,1)
IF comp_num1 =="1"
comp_val1=1
ENDIF
IF comp_num1 =="2"
comp_val1=2
ENDIF
IF comp_num1 =="3"
comp_val1=3
ENDIF
IF comp_num1 =="4"
comp_val1=4
ENDIF
IF comp_num1 =="5"
comp_val1=5
ENDIF
IF comp_num1=="6"
comp_val1=6
ENDIF
IF comp_num1 =="7"
comp_val1=7
ENDIF
IF comp_num1 =="8"
comp_val1=8
ENDIF
IF comp_num1 =="9"
comp_val1=9
ENDIF
IF comp_num1 =="0"
comp_val1=0
ENDIF
NUM_INT=comp_val1
ENDIF

IF string_length(temp_num)>=2
comp_num2=extract(temp_num,2,1)
IF comp_num2 =="1"
comp_val2=1
ENDIF
IF comp_num2 =="2"
comp_val2=2
ENDIF
IF comp_num2 =="3"
comp_val2=3
ENDIF
IF comp_num2 =="4"
comp_val2=4
ENDIF
IF comp_num2 =="5"
comp_val2=5
ENDIF
IF comp_num2 =="6"
comp_val2=6
ENDIF
IF comp_num2 =="7"
comp_val2=7
ENDIF
IF comp_num2 =="8"
comp_val2=8
ENDIF
IF comp_num2 =="9"
comp_val2=9
ENDIF
IF comp_num2 =="0"
comp_val2=0
ENDIF
NUM_INT=NUM_INT*10+comp_val2
ENDIF

IF string_length(temp_num) >= 3
comp_num3=extract(temp_num,3,1)
IF comp_num3 =="1"
comp_val3=1
ENDIF
IF comp_num3 =="2"
comp_val3=2
ENDIF
IF comp_num3 =="3"
comp_val3=3
ENDIF
IF comp_num3 =="4"
comp_val3=4
ENDIF
IF comp_num3 =="5"
comp_val3=5
ENDIF
IF comp_num3 =="6"
comp_val3=6
ENDIF
IF comp_num3 =="7"
comp_val3=7
ENDIF
IF comp_num3 =="8"
comp_val3=8
ENDIF
IF comp_num3 =="9"
comp_val3=9
ENDIF
IF comp_num3 =="0"
comp_val3=0
ENDIF
NUM_INT=NUM_INT*10 + comp_val3
ENDIF

NUM_IM="0"

/*Convert NUM_INT to NUM_IM
IF NUM_INT==0
NUM_IM="999"
ENDIF

IF NUM_INT==1
NUM_IM="910"
ENDIF

IF NUM_INT==2
NUM_IM="920"
ENDIF

IF NUM_INT==3
NUM_IM="930"
ENDIF

IF NUM_INT==4
NUM_IM="940"
ENDIF

IF NUM_INT==5
NUM_IM="950"
ENDIF

IF NUM_INT==6
NUM_IM="951"
ENDIF

IF NUM_INT==7
NUM_IM="960"
ENDIF

IF NUM_INT==8
NUM_IM="970"
ENDIF

IF string_length(TEMP_NUM) ==1
IF TEMP_NUM =="A"
NUM_IM =NUM_IM + "01"
ENDIF
ENDIF

/* ****************** DESCRICAO ******************
IF NUM_INT==0
DESCRICAO="Barra de transporte"
INGLES="Handling strap"
FRANCES="Plaque de transport"
ALEMAO="Transportsicherungsleists"
ENDIF

IF NUM_INT==1
DESCRICAO="Chapa de aperto da injeccao"
INGLES="Top clamping plate"
FRANCES="Plaque de fixation"
ALEMAO="Aufspanhplatte der spritzseite"
ENDIF

As an example of what I intend to do is the following:
my piece has number 0, so it will have my NUM_IM=999,
but if the part has number 0A, then it will have my NUM_IM=99901,
but if the part has number 0B, then it will have my NUM_IM=99902,
and so on for the rest of the alphabet.
All of this would happen for the piece with number 1.

Thank you for your attention

Best Regards,
Daniel
 
Replies continue below

Recommended for you

Complex code for a relation in every file you create.
What is the goal of the relations?
Provide some sample part names that can be used to test your code with.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
Many times I would have killed (not literally) to have an array in relations.

Still, a lot of those could be condensed using "SEARCH" as in:

comp_val3 = SEARCH("0123456789",comp_num3)-1
 
image_gjohfa.png
 
Further compression:
num_im_list="999910920930940950951960970"
num_im = extract(num_im_list, num_int*3+1, 3)

What is the function your code does not do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor