Skip to main content
1-Visitor
December 28, 2015
Question

Creating a set parameter based off file name

  • December 28, 2015
  • 1 reply
  • 4010 views


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.

1 reply

16-Pearl
December 28, 2015

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.

rstoltz1-VisitorAuthor
1-Visitor
December 28, 2015

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"

16-Pearl
December 28, 2015

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.