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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Creating a set parameter based off file name

rstoltz
3-Newcomer

Creating a set parameter based off file name


Is there a way when setting up my .start file and setting my parameters, that I can set one to autofill the file name, so I do not have to manually enter the part name everytime?


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

If you're referring to creating a parameter based on the filename, you can use the following relation:

*SET PART_NUMBER BASED ON MODEL NAME

part_number=rel_model_name()

If you use filenames like 123456789_bracket.prt, you can use a relation like:

part_number=extract(rel_model_name(),1,9)

This will extract just the first 9 characters of the filename.

Regards,

Dan N.

rstoltz
3-Newcomer
(To:dnordin)

I am trying to add this parameter to a start.prt, but when I add this parameter it uses the start.prt filename, not the one of the new part I create using this start.prt/

Example:

     sheetmetal_start.prt contains the parameter/relation part_number=extract(rel_model_name(),1,7)

     Created new part 1234567.prt. In the parameters under part_number, it says "sheetme" instead of "1234567"

Since it's a relation, it should update when you regenerate the model.  You likely just need to regenerate the model after opening it and before you go into the parameters dialog.

As an FYI, with your relation, if your filename is shorter than 7 characters, the regeneration status will always be yellow.  We run into the same issue when we start designs and the model names are simple (like bolt.prt).  Once we assign "real" names (i.e. our part numbers) to the models, the relations are successful and the status will go green.

Dan N.

rstoltz
3-Newcomer
(To:dnordin)

Ok, I'll give that a try. Thank you very much.

dschenken
21-Topaz I
(To:rstoltz)

Try

part_number = extract(rel_model_name(),1,string_length(rel_model_name())-4)

which should always work by subtracting off the last 4 characters (.prt or .asm)

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags