Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

partial file name parameter? 3

Status
Not open for further replies.

jjax

Industrial
Jan 28, 2004
19
0
0
US
Is there a way to create a parameter in my start parts that will will reference a portion of the parts file name?

ie:

filename - joepartname_axxxxxx.prt/asm

parameter- det# = &file_name*_a*<

so that parameter det# will equal the xxxxxx portion of the file name no matter if it's 1 character long or 8.

Thx in advance
Jason
 
Replies continue below

Recommended for you

Jason,

In your part, go to relations and add these sentences:

a = rel_model_name
a1=search (a, "_")
a2 = extract (a, 1, (a1+1))

examine the values:
a will give you joepartname_axxxxxx
a1 will give you 12
a2 will give you joepartname_a

To avoid these intermediar parameters, you can write the desired relation in a single sentence:

filename = extract(rel_model_name, 1, (search(rel_model_name, "_")+1))

-Hora
 
Thanks Hora,

I'm trying to build on the info you gave me and am having some trouble.

Is there any reason why this line doesn't work:

a2 = extract (a, (a1+1), (a1+5))

I have tried it and will not work that way. If I replace (a1+1) with 1 like you said it works fine but I need the info after the "_".
 
Jason,

You were right. The extract function doesn dot accept a variable like this in the second position... But I found a way to solve your problem.

As I see you need to extract the last characters, after the "_"

Please see my example below:

a = rel_model_name
a1 = search (a, "_")-1

name1 = extract (a, 1, a1)

s1 = string_length(a)
s2 = string_length(name1)+2

name2 = extract(a, s2, (s1-s2))



Now the name1 = JOEPARTNAME
name2 = AXXXXX

I think this is what you want to do.

-Hora

 
Hora,

You are amazing. [thumbsup2] Clearly
star.gif
worthy.

Is there a more complete listing of relation operations that I can add to my FAQ Mathematical Operators used in Pro/E Relations (faq554-970)?


Best regards,

Matthew Ian Loew
"I don't grow up. In me is the small child of my early days" -- M.C. Escher

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
Hi Tofflemire,

Split a string in two sub-strings, given a specific character (in Jason's case "_")

String = JOEPARTNAME_AXXXXXX

After applying these functions, you will have:

String1 = JOEPARTNAME
String2 = AXXXXX

The tricky part was the EXTRACT function which does not accept a float variable as second argument.

I think that evaluating the length of the string with the function STRING_LENGTH the result is an integer, which is accepted by the EXTRACT function. And this solved the problem.

-Hora
 
Hi Hora,

Thanks for the info. Why would you want to do this? Are you using one of these strings as a parameter on a drawing such as part number. Why not just name the file(s) the way you want them to be.

I'm confused as to why the naming convention is set up to name JOEPARTNAME_AXXXXX.PRT. Why do you name the files with a user name in it? You can create a parameter to enter the users name in the field.

Thanks

Tofflemire
 
Toff,

Jason asked how to split this string. I don't know if the real part name is JOEPARTNAME_AXXXXX or it was just an example.

But many of us may want to extract a portion of the string for different reasons (BOM, revisions, materials etc, etc). Personaly I made this several times, but always I took in consideration only the first part. Jason's question was quite challenging.

If you have INTRALINK and you want to add an automatic revision on the drawing cartrige, then you will use this relation in your revision box:

&pdmrev:d (d is for drawing)

The &pdmrev variable will hold something like this :

pdmrevrev:d = A-10 (an example)

You don't need to see the "-10" in your revision box if you want to display only the major revision. Then you can extract only the first part odf the string.

But if you need to see only the minor revision "-10" you can extract the second part.

Try it! It's nice to have the revision block filled in automaticaly.

-Hora
 
Status
Not open for further replies.
Back
Top