Skip to main content
10-Marble
July 17, 2024
Solved

Save as part parameter

  • July 17, 2024
  • 2 replies
  • 1678 views

I would like to create a parameter that stores the previous part number or name of the part that the part was saved from.  


For example if I have a part "Gear1.prt" and I save as to a new part "Gear2.prt" I want to store a parameter when doing a save-as that says "Gear1".  That way users that perform a save as automatically have a history of where this design was made from.  It can be useful when going through a parts history.   I don't want to make it a type in parameter because users would forget to add this information.

 

Does anybody have any insights into how this could be done?  

Best answer by KenFarley

Thought about it a bit more. I think the crux of the problem is that you need to detect and respond to a change of model name. So, you need some way to know it has changed. Thus, I'd define two parameters:

currentModel  -> A String parameter, will store the current model name

pastModel -> A String parameter, will store the previous model name

 

The "trick" is to use the relation function rel_model_name(), which provides an ALL CAPS string of the current model name, or name of the current file without the .prt, .asm, etc. The relations I'd add to the model to use the above parameters would be:

IF currentModel <> rel_model_name()
 pastModel = currentModel
ENDIF
currentModel = rel_model_name()

Thus if you copy a file to another file, via "Save As" or whatever, when you open that file, this relation will find that the file name is not what it was, and via the "IF" clause, set the past model name to what it was before, then update the current model name to the current file name.

Some possible problems with this approach:

(1) I don't know how it will work with family table parts. Parameter will probably change for every instance and not in a good way.

(2) You have to live with the relation being executed every time you regenerate your model. It's not a lot, but still...

(3) You have to put the relations and parameters in every file you want them in.

2 replies

21-Topaz II
July 17, 2024

Can't think of a method to do what you want with relations and such. It's an unecessary exercise, anyway. Creo already stores this information for you.

(1) Try copying a file to another file via a "Save As" operation.

(2) Open the copied file.

(3) Access the file history via Tools->Investigate->File History

 

You'll see the first entry in the table will be something like "The model was copied from..." and it will list the name of the file you copied from.

I use this all the time to figure out who messed up one of my models. Or what part/assembly template I started with.

KenFarley21-Topaz IIAnswer
21-Topaz II
July 17, 2024

Thought about it a bit more. I think the crux of the problem is that you need to detect and respond to a change of model name. So, you need some way to know it has changed. Thus, I'd define two parameters:

currentModel  -> A String parameter, will store the current model name

pastModel -> A String parameter, will store the previous model name

 

The "trick" is to use the relation function rel_model_name(), which provides an ALL CAPS string of the current model name, or name of the current file without the .prt, .asm, etc. The relations I'd add to the model to use the above parameters would be:

IF currentModel <> rel_model_name()
 pastModel = currentModel
ENDIF
currentModel = rel_model_name()

Thus if you copy a file to another file, via "Save As" or whatever, when you open that file, this relation will find that the file name is not what it was, and via the "IF" clause, set the past model name to what it was before, then update the current model name to the current file name.

Some possible problems with this approach:

(1) I don't know how it will work with family table parts. Parameter will probably change for every instance and not in a good way.

(2) You have to live with the relation being executed every time you regenerate your model. It's not a lot, but still...

(3) You have to put the relations and parameters in every file you want them in.

AndrewK
Community Manager
July 22, 2024

Hi @CS_10428158,


I wanted to follow up with you on your post to see if your question has been answered. If so, please mark KenFarley's reply as the Accepted Solution for the benefit of other members who may have the same question.

Of course, if you have more to share on your issue, please let the Community know.

 

Thanks!