Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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.
Solved! Go to Solution.
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
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.
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.
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
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
Thanks Christopher. I'll try that too.
That's a great tip, Christopher! Thanks.