Hi all,
I am working on automating few flows in Creo 8.0.3 using jlink.
Is there a way to identify if a model has been modified in creo? I have tried few apis provided in jlink toolkit documentation - GetIsModified() and GetVersionStamp(). Although the output of these methods depend on 'save' action triggered by users. I am looking for a way to track changes in files since the beginning of the session and to identify if any modification in sub-assembly or components changes the parent assembly as well.
Java provides a way to track file changes in a directory using WatchService
I am successfully able to identify if a sub-assembly or its parent has been modified by registering the workspace and track changes using this method. Are there any limitations to this approach? And is this how creo tracks changes in a model?
Thanks
Solved! Go to Solution.
Maybe in JLink GetVersionStamp() is driven by a save action, but not in Toolkit. Prepare a notify function to save the stamp linked to a model on open. Now you can compare if a model was changed if you want to check that. With a Save notify function you can reset the counter if required.
GetIsModified is method used to do this .. but limitation is that it return true also if user do nothing with model but creo does .. for example some calculations during regeneration - geometry or props of model like params, material etc. may not be changed so use this method carefully.
WatchService may be usefull but you need to be careful too because Creo handle model files not in the way you one would expect. I am not sure what was the situation when I tested it but as I remember I tried to rename modle so watching files in whole directory and Creo did like 3 or 4 file operations where you would except only one - it was like creating new file, copying the file, deleting old file and renaming new file (as I say I cannot remember details, but it surprised me)
I think your only way is to do reverse engineering how Creo is handling model modification and file changes and try to fit the logic to for your application. Maybe make some combination of both GetIsModified and file watcher to achieve what you need.
Hope this helped.
Maybe in JLink GetVersionStamp() is driven by a save action, but not in Toolkit. Prepare a notify function to save the stamp linked to a model on open. Now you can compare if a model was changed if you want to check that. With a Save notify function you can reset the counter if required.