Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi everyone
If i want to write a relation in a customized way in creo 3.0 then is it possible, suppose i have a parameter named Model_name = 1238zx-0128p0000 now i want to create another parameter (say DRG_NAME ) by using this model_name parameter but my new parameter should be DRG_NAME=1238ZX-0128P , i want to remove the last four digit of my Model_name parameter and want to store it in a new parameter as DRG_NAME.
Solved! Go to Solution.
I provide some examples of bom relations I use that may help in understanding your needs.
this uses the functions James62 recommends for you to study.
bom_qty=rpt_qty
bom_name=asm_mbr_name
bom_nomen=""
/*ASSIGN CHOSEN NOMENCLATURE PARAMETERS
/* COPY AND PASTE THIS SECTION.
/* THEN CHANGE CHARACTER LENGTH
/* AND NAME_CHECK ACCORDINGLY
name_check=EXTRACT(bom_name,1,7)
IF name_check=="MS16555"
bom_nomen="PIN, STRAIGHT, HEADLESS"
ENDIF
IF name_check=="MS20995"
bom_qty="AR"
ENDIF
/*SPECIAL CASES
/*ASSIGN REMAINING NOMENCLATURE PARAMETERS
IF bom_nomen==""
bom_nomen=asm_mbr_nomenclature
ENDIF
/* REMEMBER TO CHANGE NOMENCLATURE / DESCRIPTION TO
/* rpt.rel.bom_nomen
/*****REPLACE OR REMOVE UNDERSCORE*****
/* ASSIGN THE MODEL NAME TO A PARAMETER
old_name = asm_mbr_name
/* ASSIGN THE LENGTH OF THE STRING TO A PARAMETER
len = STRING_LENGTH(OLD_NAME)
/* SEARCH FOR THE FIRST UNDERSCORE AND ASSIGN ITS POSITION TO PARAMETER
pos = SEARCH(OLD_NAME, '_')
/* SEARCH() RETURNS ZERO IF NOTHING FOUND SO...
IF pos > 0
/* EXTRACT THE ORIGINAL NAME UP TO THE UNDERSCORE
bom_name = EXTRACT(old_name, 1, POS-1)
/* EXTRACT THE REMAINING STRING
rem = EXTRACT(old_name, pos+1, len-pos)
/* ADD THE DECIMAL POINT AND THE REMAINING STRING
/*bom_name = bom_name + '.' + rem
ENDIF
/* SINCE WE CANNOT WRITE ANY LOOP STATEMENTS
/* REPEAT THE CODE BELOW FOR THE MAX NUMBER
/* OF UNDERSCORES AS IS NECESSARY.
/* THE IF STATEMENT PREVENTS UNECESSARY
/* NUMBER CRUNCHING
/* EX: ABC_DEF_GHI_JKL HAS 3 UNDERSCORES
/* THE SECTION BELOW NEEDS TO EXIST TWICE
old_name = bom_name
pos = SEARCH(old_name, '_')
IF pos > 0
bom_name = EXTRACT(old_name, 1, pos-1)
rem = EXTRACT(old_name, pos+1, len-pos)
bom_name = bom_name + '.' + rem
ENDIF
/* REMEMBER TO CHANGE THE PART NUMBER TO
/* rpt.rel.bom_name
/* renaming a part
/*bom_name=asm_mbr_name
hi,
Have a look at the following 4 functions in help files
rel_model_name()
string_length()
search()
extract()
I provide some examples of bom relations I use that may help in understanding your needs.
this uses the functions James62 recommends for you to study.
bom_qty=rpt_qty
bom_name=asm_mbr_name
bom_nomen=""
/*ASSIGN CHOSEN NOMENCLATURE PARAMETERS
/* COPY AND PASTE THIS SECTION.
/* THEN CHANGE CHARACTER LENGTH
/* AND NAME_CHECK ACCORDINGLY
name_check=EXTRACT(bom_name,1,7)
IF name_check=="MS16555"
bom_nomen="PIN, STRAIGHT, HEADLESS"
ENDIF
IF name_check=="MS20995"
bom_qty="AR"
ENDIF
/*SPECIAL CASES
/*ASSIGN REMAINING NOMENCLATURE PARAMETERS
IF bom_nomen==""
bom_nomen=asm_mbr_nomenclature
ENDIF
/* REMEMBER TO CHANGE NOMENCLATURE / DESCRIPTION TO
/* rpt.rel.bom_nomen
/*****REPLACE OR REMOVE UNDERSCORE*****
/* ASSIGN THE MODEL NAME TO A PARAMETER
old_name = asm_mbr_name
/* ASSIGN THE LENGTH OF THE STRING TO A PARAMETER
len = STRING_LENGTH(OLD_NAME)
/* SEARCH FOR THE FIRST UNDERSCORE AND ASSIGN ITS POSITION TO PARAMETER
pos = SEARCH(OLD_NAME, '_')
/* SEARCH() RETURNS ZERO IF NOTHING FOUND SO...
IF pos > 0
/* EXTRACT THE ORIGINAL NAME UP TO THE UNDERSCORE
bom_name = EXTRACT(old_name, 1, POS-1)
/* EXTRACT THE REMAINING STRING
rem = EXTRACT(old_name, pos+1, len-pos)
/* ADD THE DECIMAL POINT AND THE REMAINING STRING
/*bom_name = bom_name + '.' + rem
ENDIF
/* SINCE WE CANNOT WRITE ANY LOOP STATEMENTS
/* REPEAT THE CODE BELOW FOR THE MAX NUMBER
/* OF UNDERSCORES AS IS NECESSARY.
/* THE IF STATEMENT PREVENTS UNECESSARY
/* NUMBER CRUNCHING
/* EX: ABC_DEF_GHI_JKL HAS 3 UNDERSCORES
/* THE SECTION BELOW NEEDS TO EXIST TWICE
old_name = bom_name
pos = SEARCH(old_name, '_')
IF pos > 0
bom_name = EXTRACT(old_name, 1, pos-1)
rem = EXTRACT(old_name, pos+1, len-pos)
bom_name = bom_name + '.' + rem
ENDIF
/* REMEMBER TO CHANGE THE PART NUMBER TO
/* rpt.rel.bom_name
/* renaming a part
/*bom_name=asm_mbr_name
hi Ron St.Pierre
Thank you very much i got my solution by going through the way you suggested.
You're welcome. Glad it helped.