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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Relations help......

ptc-222962
1-Newbie

Relations help......

HI All,

This should be simple but I’m having issues, I'm attempting to write the relation shown directly below which works fine when this exact P/N is used. The issue is..... I wantthe first five characters (12345) and the last two (00)to be a wildcards so anywherethe relation see's "-67-89-" it'll complete the other parameters automatically.

if PART_NUMBER =="12345-67-89-00"
MATERIAL = "WOOD"
MATERIAL_SPEC = "RED OAK"
FINISH_CODE = "89"
ENDIF

I've attempted to use asterisksfor wildcards (as below)… this doesn’t work…. Any help would be appreciated!


if PART_NUMBER =="*-67-89-*"
MATERIAL = "WOOD"
MATERIAL_SPEC = "RED OAK"
FINISH_CODE = "89"
ENDIF

Thanks,

Doug


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.
4 REPLIES 4

Use the extract(string, position, length) function to pull out only what
you want.

PART_NUMBER_MIDDLE = extract(PART_NUMBER,6,7)
IF PART_NUMBER_MIDDLE == "-67-89-"
MATERIAL = "WOOD"
MATERIAL_SPEC = "RED OAK"
FINISH_CODE = "89"
ENDIF

Hope that helps,

Brian S. Lynn
Technical Coordinator, Product Engineering
RonThellen
14-Alexandrite
(To:ptc-222962)

That solution works as long as PART_NUMBER always starts with five characters before the first “-“, which may or may not be the case.



The following provides a little more flexibility (I added the else statement for testing purposes, but it could be useful in the final relation):



if search( PART_NUMBER, "-67-89-") > 0

MATERIAL = "WOOD"

MATERIAL_SPEC = "RED OAK"

FINISH_CODE = "89"

else

MATERIAL = "???"

MATERIAL_SPEC = "???"

FINISH_CODE = "???"

endif



The “search” function looks for the specified string. If it is found, it returns a non-zero value. If it is not found, it returns 0.



Ron Thellen
CAD Administrator
Engineering & Manufacturing Applications
Government Communications Systems Division
Harris Corporation
321-729-7502






You could use the search function





RESULT = search(PART_NUMBER, "-67-89-"

IF RESULT > 0

MATERIAL = "WOOD"

MATERIAL_SPEC = "RED OAK"

FINISH_CODE = "89"

ENDIF





The search() function returns the location in the string of the search term
(in your case, 6, since the - is the 6th character in the string. If the
search term is not found, it returns 0.





--



Lyle Beidler
MGS Inc
178 Muddy Creek Church Rd
Denver PA 17517
717-336-7528
Fax 717-336-0514
<">mailto:-> -
<">http://www.mgsincorporated.com>
complete the other parameters automatically.

if PART_NUMBER =="12345-67-89-00"
MATERIAL = "WOOD"
MATERIAL_SPEC = "RED OAK"
FINISH_CODE = "89"
ENDIF

I've attempted to use asterisks for wildcards (as below). this doesn't
work.. Any help would be appreciated!


if PART_NUMBER =="*-67-89-*"
MATERIAL = "WOOD"
MAT...










Hi All,

Several people suggested thesame method (below) and it works fine! Thanks to all!Doug

if search( PART_NUMBER, "-67-89-") > 0

MATERIAL = "WOOD"

MATERIAL_SPEC = "RED OAK"

FINISH_CODE = "89"

endif

Top Tags