Skip to main content
1-Visitor
August 1, 2015
Solved

How to extract pieces of strings to assign to a parameter

  • August 1, 2015
  • 6 replies
  • 4605 views

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.
Best answer by TomD.inPDX

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

6 replies

17-Peridot
August 1, 2015

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.

abesau1-VisitorAuthor
1-Visitor
August 1, 2015


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.

17-Peridot
August 1, 2015

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