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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Show file save iteration number in drawing

Wouter
11-Garnet

Show file save iteration number in drawing

Hello everyone,

 

I'm trying to find a way to show the file save iteration number in a drawing in Creo (Version 4.0 and higher). It will be used for projects without a PDM system to show the exact save iteration, in addition to a revision parameter.

For example for a drawing of a part named DUMMY.PRT.35 I would like to extract the number 35 either directly in the drawing and show it in a note -or- in the part model by placing it into a parameter I can reference in a drawing note.
I haven't found if this is possible somehow. The rel_model_name and model_name parameters do not seem to provide this functionality?

Any help is appreciated!

ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:Wouter)

I would not use the file based iteration. I would compare the model stamp, if the model stamp has changed bump a parameter.

 

In the video the part file is open, next 

 

  1. Open the related Drawing
  2. Show the table parameter for the Drawing and the Part
  3. Start a Dummy App just for testing
  4. Save the Drawing - No effect
  5. Connect with the App to Creo
  6. See how to get the full path of a model
  7. Copy the prepared code into the App
  8. Source the code, make it available
  9. Activate the notify function
  10. Now save, and the model and drawing parameter gets updated

 

 

 

 

The source code, more comments then code 🙂

 

 

 

 

# this is the call to activate a callback
#
#  ps_notify set MODEL_SAVE_PRE Update_Param_On_Save
#
# After this is called the script Update_Param_On_Save 
# will be called just before the final save

proc Update_Param_On_Save {} {
# Get the current model 
# and the file extension
	set MODEL [ps_model cur]
	set EXT	  [ps_model ext -model $MODEL]

# Now decide what to do
# for PRT or ASM just update the parameter
# for a drawing get the model and update both
	switch $EXT	{
		ASM	-
		PRT	{
			Iteration_File_Param_Set $MODEL
		}

		DRW	{
			# Assume for test one attached model
			set DrwModel [ps_draw list -draw [ps_model cur]]

			Iteration_File_Param_Set $DrwModel
			Iteration_File_Param_Set $MODEL
# Just show the updated table data
			ps_table update -draw $MODEL

		}

		default	{

			ps_mess -icon warn "Model $MODEL not supported"
		}


	}
# It is a PRE Notifier, you can abort
# if return is an integer
# 	if not 0 save is aborted
# else just continue and save
	return 0
}


#
# Just set a model parameter based on the NEXT iteration
#
proc Iteration_File_Param_Set {MODEL} {

	set filename [ps_model filename -model $MODEL]
# extension is .35 need 35
# . is 0 so from 1 to end no further checks for demo here
	set iteration [string range [file extension $filename] 1 end]
	
# if you save 20 -you will get 21
	incr iteration

	ps_param set -model $MODEL ITERATION STRING $iteration

	ps_mess -icon warn "Model $MODEL iteration parameter updated to '$iteration'"
}


 

 

 

View solution in original post

23 REPLIES 23
MartinHanak
24-Ruby III
(To:Wouter)

Hi,

BASIC INFO -> if you open drawing then Creo opens the latest versions of drawing models.

So how would you like to run your "method"? Please provide simple example.

 


Martin Hanák

Hello Martin, 

 

I'm not sure how to explain this in a different way, but this is an example of what it should look like:
Files on disk:

240320_6503_TEST.png

Drawing:

240320_6504_DRW0001.png


Note that this in only meant for cases in which no PDM system is available (in which case I would use e.g. PTC_WM_VERSION and PTC_WM_VERSION:D ). 

 


 

MartinHanak
24-Ruby III
(To:Wouter)


@Wouter wrote:

Hello Martin, 

 

I'm not sure how to explain this in a different way, but this is an example of what it should look like:
Files on disk:

240320_6503_TEST.png

Drawing:

240320_6504_DRW0001.png


Note that this in only meant for cases in which no PDM system is available (in which case I would use e.g. PTC_WM_VERSION and PTC_WM_VERSION:D ). 

 


 


Hi,

I understand your picture. However, the data lifecycle needs to be explained.

I would expect this kind of lifecycle:

  • interation numbers of drawing and part start at .1
  • during InWork stage interation numbers change every time you save
  • when project goes into Relased stage then purge action is applied and requested values of interation numbers are included into drawing table

NOTE: Creo enables you to open DUMMY.PRT.35, but Creo does not remember .35 information. Creo only knows that DUMMY.PRT is located in session memory.


Martin Hanák

Yeah, I think the number is added only when Creo goes to save. If it sees a model with the same name, it saves the file and appends the next number. Nothing is stored in the Creo file that relates to the number of the file on the disk.

I think you'd be better off having a parameter in each file that is the "version" or whatever you are calling it, where the person doing the work has to manually change it whenever they are saving their work at a particular "finished" state. Manual = could be forgotten, but not a number that is incremented every time you save a file.

Maybe another way of hacking this without PDM would be to keep track of the number of times the model has been regenerated:

pausob_0-1710950139205.png

(then display &MY_VERSION in the drawing title block)

 

There would still be issues that require a manual procedure / check.  For example, when you add a feature, the software does not necessarily regenerate the model.  Another thing is changing layer states would not trigger a regeneration but mark the model as modified.  So there could be cases where two different looking models have the same value of MY_VERSION parameter...  

Yes, I'm aware that the fact that the number is added when saving will likely be an issue when showing the DRW save iteration, but for the PRT it could work in theory, if there is a way to extract the iteration number. It's acceptable if it doesn't work for the DRW. 

 

The whole idea is to avoid the user having to manually change a second parameter save iteration (in addition to the revision parameter).

I would not be suprised if this is not possible at all (without the use of an external utility) in stand-alone Creo. One of the advantages of a PDM system is that this issue doesn't even occur, becasue the needed information is automatically stored in parameters by default.

 

Your proposal of a version parameter that automatically increments when saving could be a great workaround. I'll look into it!

Wouter
11-Garnet
(To:Wouter)

I looked into ways to automatically update a parameter when saving, but could not find a way. I can create a relation to increment a parameter value, but it will be run either pre- or post-regeneration, which is not what I need.

I also couldn't find a way to do this using ModelCHECK, because it can only add, delete or rename parameters, or add relations. It doesn't seem to be able to execute a specific relation only when saving.

I could write an external script to 'catch' the save command in Creo and have it update the parameter, but I do not want to use an external program.

 

So if anybody knows another way that might work, please let me know. If there's no way I'll just leave it in the drawing as a field for manual entry.

Well, are you asking about out-of-the box Creo or can you use external scripting?  Even then, Creo does not prevent you from simply "saving the file" instead of running a mapkey that calls the external script, sets the version flag, etc.., before issuing the save command...

That's why I thought the regeneration count would be a pretty good way of tracking the model version against what's published, but seems that's not what you want to do here.

Wouter
11-Garnet
(To:pausob)

I was thinking about maybe running a script that tracks CTRL+S and also replacing the save button in Creo, but these all seems impractical and not fool-proof.

The problem with regeneration is that even when the model is not changed and I regenerate multiple times the counter is increased. This could lead to unintended increase in version number, which would lead to confusion.

 

Maybe if I write a mapkey for an external script that retrieves the current save iteration of the file, sets a "version" parameter to that number+1 and then saves the part. Then the number version and iteration will match. Basically it would be an "update version number and save" function. Disadvantage is that the user must run this automatically. I have not found a way to trigger a mapkey or script when saving in Creo.

 

I'm still not sure if any of the ideas would work well in practice... have to think it through.


@Wouter wrote:

I was thinking about maybe running a script that tracks CTRL+S and also replacing the save button in Creo, but these all seems impractical and not fool-proof.

The problem with regeneration is that even when the model is not changed and I regenerate multiple times the counter is increased. This could lead to unintended increase in version number, which would lead to confusion.

 

Yeah... though in your original scheme, a model could be saved multiple times without actually "changing anything", increasing the file save counter (e.g. create a datum plane, delete it, save).

 

I get that with this # of regeneration times tracking scheme, it is "easier" to increment the version counter.

And figuring out later on which particular file has the CAD model at a particular regeneration count is a bit of a headache...

 

But still, at the end of the day, you'll have two drawings and one will have a model version number that is larger than the other.  That is presumably the newer print...

Wouter
11-Garnet
(To:pausob)

Just for information: The point of having the save iteration number is to know exactly which iteration of a model is used fo a specific drawing revision. So that even if a user (inadvertently) saves the model additional times (with or without changing anything), it will still be clear which iteration the drawing is based on. 

BenLoosli
23-Emerald II
(To:Wouter)

The problem will be in opening the EXACT assembly even with iterations as the system does not track iterations used in an assembly. Windchill can do it as it is a database that stores that information. When you open an assembly with the As Saved mode, the system should open the iterations that the assembly was saved with. In a disk filing system, you do not have the relationships stored in order to really open an assembly in its As Saved configuration.

You are correct and I'm well aware of the potential issues. The point is that I would have a way to determine the originally matching saved model file and drawing file. Unfortunately, not all users are prudent enough when storing their data, creating backups, and purging. New users often struggle a bit with it in the beginning. And sometimes people just don't realise they inadvertently changed and saved data. I will help them, explain them (again) how to correctly store the data and fix it if needed. That is one of the cases where a file save iteration number would be useful.

It would be really great to have a PDM system like Windchill, but we work for many different customers and often directly in their own PDM (Windchill). Having Windchill ourselves just for the projects where we have more than a few users at the same time working on a project for a customer without PDM system is just too expensive. Especially considering that we're using at least 5 of the major CAD software programs.
(Side note: On my own initiative, in parallel I'm also looking for affordable PDM solutions that could handle Creo, SolidWorks, NX, Catia data etc. at the same time, without vendor restrictions. That could make the entire initial issue obsolete.)

pushkarkhanna
14-Alexandrite
(To:Wouter)

Hi

The parameter for the iteration is &PTC_WM_ITERATION.

I think that is what you need

pushkarkhanna_0-1710949516715.png

you can also put the revision & version.

 

Pushkar Khanna

I think the PTC_WM_... parameters are only there if you are using Windchill. The question originally asked was how to do this kind of thing for models not controlled by a PDM system.

BenLoosli
23-Emerald II
(To:Wouter)

If you have a parameter in your file for revision, that should be all you need to track changes. The iteration will increment with every save and is really meaningless as Creo will always open the latest iteration by default. 

 

Please explain in a little more detail the end objective of putting the file iterations on the drawings. The drawing iteration will be out of date as soon as you do a save with the open iteration.

The point of having the save iteration number is to know exactly which iteration of a model is used fo a specific drawing revision. So that even if a user (inadvertently) saves the model additional times (with or without changing anything), it will still be clear which iteration the drawing is based on. 

The intended use is somewhat similar to the PDM functionality that allows you to open a drawing with the exact iteration of the model it was saved with, not with an iteration of the model that was created much later. 

Wouter
11-Garnet
(To:Wouter)

To summarise the findings from all your replies and my testing:

 

It does not seem to be possible to extract the save iteration number directy in Creo without the use of (external) scripting. To me this is not really unexpected, becasue it is not common functionality. 

I will either try writing a script or have the user fill in the drawing field manually only when it's really necessary. 

 

Thank you all for your support! 

Hidetaka
15-Moonstone
(To:Wouter)

I think it is possible with script, and it is not difficult.
I usually use Autohotkey for this kind of purposes. In this case, I would do as follow:
1. Create a parameter named ITERATION and assign a number to it.

2. Update ITERATION to another number.
3. Get the part of the trail file that does the update in step 2.

4. Create a mapkey that runs a certain trail file, eg. t1.txt

5. In autohotkey, create a shortcut with Ctrl S.
This shortcut overloads the Ctrl S you would use to save a model, i.e., when user presses Ctrl S, the model is not saved, but the shortcut is triggered. And here is what the shortcut does:

i) Get current iteration number (by reading Creo Title and use PathSplit)
ii) Generate new iteration number (plus 1 to current number)

iii) Generate the trail file that will update ITERATION parameter to the new iteration number, based on what we got in step 3. Save that trail file as t1.txt

iv) Trigger the mapkey to run t1.txt

And it is done. You can do whatever you want with ITERATION, and that parameter is updated every time an user tries to save the model with Ctrl S.
You can also replace the save icon in the Creo UI with an icon that run the Ctrl S shortcut. It is a little more advanced, but also not difficult at all.

Wouter
11-Garnet
(To:Hidetaka)

This is basically what I had in mind, since I have some experience with AutoIt scripting and AutoHotkey. What I don't like about it, is that I have to have additional software constantly running in the background for all users, and that I would have to change the UI for all Creo versions and configurations we use (a lot of them).

RPN
17-Peridot
17-Peridot
(To:Wouter)

I would not use the file based iteration. I would compare the model stamp, if the model stamp has changed bump a parameter.

 

In the video the part file is open, next 

 

  1. Open the related Drawing
  2. Show the table parameter for the Drawing and the Part
  3. Start a Dummy App just for testing
  4. Save the Drawing - No effect
  5. Connect with the App to Creo
  6. See how to get the full path of a model
  7. Copy the prepared code into the App
  8. Source the code, make it available
  9. Activate the notify function
  10. Now save, and the model and drawing parameter gets updated

 

 

 

 

The source code, more comments then code 🙂

 

 

 

 

# this is the call to activate a callback
#
#  ps_notify set MODEL_SAVE_PRE Update_Param_On_Save
#
# After this is called the script Update_Param_On_Save 
# will be called just before the final save

proc Update_Param_On_Save {} {
# Get the current model 
# and the file extension
	set MODEL [ps_model cur]
	set EXT	  [ps_model ext -model $MODEL]

# Now decide what to do
# for PRT or ASM just update the parameter
# for a drawing get the model and update both
	switch $EXT	{
		ASM	-
		PRT	{
			Iteration_File_Param_Set $MODEL
		}

		DRW	{
			# Assume for test one attached model
			set DrwModel [ps_draw list -draw [ps_model cur]]

			Iteration_File_Param_Set $DrwModel
			Iteration_File_Param_Set $MODEL
# Just show the updated table data
			ps_table update -draw $MODEL

		}

		default	{

			ps_mess -icon warn "Model $MODEL not supported"
		}


	}
# It is a PRE Notifier, you can abort
# if return is an integer
# 	if not 0 save is aborted
# else just continue and save
	return 0
}


#
# Just set a model parameter based on the NEXT iteration
#
proc Iteration_File_Param_Set {MODEL} {

	set filename [ps_model filename -model $MODEL]
# extension is .35 need 35
# . is 0 so from 1 to end no further checks for demo here
	set iteration [string range [file extension $filename] 1 end]
	
# if you save 20 -you will get 21
	incr iteration

	ps_param set -model $MODEL ITERATION STRING $iteration

	ps_mess -icon warn "Model $MODEL iteration parameter updated to '$iteration'"
}


 

 

 

Wouter
11-Garnet
(To:RPN)

Wow, this looks really good!
I have never worked with scripting in Creo, so this goes beyond my understanding. I'll try to find some time to look into this soon.

Wouter
11-Garnet
(To:Wouter)

I found just a little time to look into your solution, but since I have no experience at all with scripting in/for Creo with p-shell, I think it will take me too much time to make it work to make it worth my time. I couldn't even find PTC documentation on it and if it requires a specific license to use.

 

I do want to thank you again for putting in all the effort to find a possible solution and for making the video! I hope someone else can put it to good use.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags