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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to extract pieces of strings to assign to a parameter

abesau
10-Marble

How to extract pieces of strings to assign to a parameter

I need help extracting a string from a system parameter to assign it to a user defined parameter.

Any help would be greatly appreciated.  Please see attached where I explain better what I'm trying

to accomplish.

Update: been trying and it doesn't like system parameters such as model_name.  I can use any other user defined

parameter and it works fine.


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
TomD.inPDX
17-Peridot
(To:abesau)

In the case where the filename length is not fixed, you will have to use the if/else/endif solution to test the last character until you find a underscore or period.

Here is an extensive use-case...  see the 1st comment below the document

Architectural Dimension Converter: Creo 2.0 + references

View solution in original post

6 REPLIES 6
TomD.inPDX
17-Peridot
(To:abesau)

If I understand what you are asking, you are also having trouble making the model_name parameter into relations.

This is the trick to make the current model name a relation.  This can be manipulated to extract the substring.

model_name-to-relations.PNG

The text string in the graphics window is &mypart in annotation.


Excellent!  Thanks for your help TomD.inPDX, Got me going in the right direction.

Here's the relation that worked for now:

part_number=(rel_model_name)

part_number=extract(part_number,1,9)

RESULTS IN:

part_number = AA-00-910 (this is good)

But what happens when the part number has more than nine characters?

For example, now I have an assembly where the model_name = AA-00-1234_route.asm

If I use the above expression:

part_number=(rel_model_name)

part_number=extract(part_number,1,9)

would yield:

part_number = AA-00-123 (truncating the part number, it will leave out the number "4" resulting in an incorrect part_number.

TomD.inPDX
17-Peridot
(To:abesau)

In the case where the filename length is not fixed, you will have to use the if/else/endif solution to test the last character until you find a underscore or period.

Here is an extensive use-case...  see the 1st comment below the document

Architectural Dimension Converter: Creo 2.0 + references

Chris3
21-Topaz I
(To:abesau)

If you want to clip at an underscore, you could use something like this:

part_number = extract(rel_model_name,1,search(extract(rel_model_name,1,string_length(rel_model_name)),"_")-1)

For your example above, AA-00-1234_route.asm will become AA-00-1234

abesau
10-Marble
(To:Chris3)

Thanks Christopher.  I'll try that too.

TomD.inPDX
17-Peridot
(To:Chris3)

That's a great tip, Christopher!  Thanks.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags