Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

RELATIONS

AlbertHE

New member
Hello my friends,


I'm looking for the system of transform the signs "_" in ".".


I want use the part names writing a "_" when is a comma, and then create a parameter with a relation converting this signs "_" in points "." to use this codification in our organization system.


For example, I have a part named "CD1-M2_5x12_5-Z" and then I'd like an automatic conversion in aparameter that appears as "CD1-M2.5x12.5-Z".


The reason is because Pro/E software doesn't allow to use points in the part names.


Big hugs from Barcelona,


Albert
 
Hi,


the parameter name is "code_ot", but my problem i sthat I don't know how write this in relations.





Thanks,


Albert
 
/* ASSIGN THE MODEL NAME TO A PARAMETER
OLD_NAME = REL_MODEL_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
NEW_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
NEW_NAME = NEW_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


OLD_NAME = NEW_NAME
POS = SEARCH(OLD_NAME, '_')
IF POS > 0
NEW_NAME = EXTRACT(OLD_NAME, 1, POS-1)
REM = EXTRACT(OLD_NAME, POS+1, LEN-POS)
NEW_NAME = NEW_NAME + '.' + REM
ENDIF
 
Hi,


thanks a lot. I'll try with it.


Now I understand why it's not easy andobvious . . . my godness!!!





Thank you very much again,


Albert
 
You must copy & pastethe last seven lines of the code enough times to cover the maximum number of underscores that you think you will need. To cover the example above, you would need to copy and paste the code at least two more times.
 
copyboy said:
/* ASSIGN THE MODEL NAME TO A PARAMETER
OLD_NAME = REL_MODEL_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
NEW_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
NEW_NAME = NEW_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


OLD_NAME = NEW_NAME
POS = SEARCH(OLD_NAME, '_')
IF POS > 0
NEW_NAME = EXTRACT(OLD_NAME, 1, POS-1)
REM = EXTRACT(OLD_NAME, POS+1, LEN-POS)
NEW_NAME = NEW_NAME + '.' + REM
ENDIF





Copyboy, good info there, is there any kind of documentation showing the commands and syntax used above?
 
Help > Help Center > Fundamentals > Pro/ENGINEER Fundamentals


Search for the word "extract"


Search for the word "string_length"
 

Sponsor

Articles From 3DCAD World

Back
Top