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

Add Toolkit API get hold of active Creo trail file name

Add Toolkit API get hold of active Creo trail file name

A Toolkit application or Object Toolkit application could benefit from being able to read from the trail file during or after a Creo session.

One possibility that comes to mind is to read more detailed error descriptions for problems for which the API just returns the general PRO_TK_GENERAL_ERROR.

For example trying to open a DRW with missing dependencies or opening a file created by an educational version of Creo in a commercial version of Creo.

In both cases PRO_TK_GENERAL_ERROR is returned, but an application cannot tell the difference between the two error cases.

This is particularly relevant when running Creo in hidden batch mode.

The name of the Creo trail file is "trail.txt.[n]".

Request: provide an API to get hold of the current trail file name.

Other users interested in this functionality:

Pro/Toolkit access to audit trail information

http://communities.ptc.com/message/12917#12917

3 Comments
Amethyst

It is already possible to get this information. For a trail file located in "<WORKING_DIR>\Trail\", you would use the following code:

  ProPath working_w, trail_w;

  ProCharPath working, trail;

  err = ProDirectoryCurrentGet(working_w);

    ProWstringToString(working, working_w);

    strcpy_s(trail, working);

    strcat_s(trail, "Trail\\");

    ProStringToWstring(trail_w, trail);

  ProPath *files;

    err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&files);

  ProPath *subdirs;

    err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&subdirs);

  err = ProFilesList(trail_w,L"*.txt", PRO_FILE_LIST_LATEST, &files, &subdirs);

This would return all "*.txt" files within the Trail file folder (which, should only be trail.txt). The label PRO_FILE_LIST_LATEST ensures that you would always get the active trail file (at least, the one with the newest version).  

If you wanted to do even more verification, you could use ProFilenameParse to ensure that the file is named "trail.txt", as well as to get the version.

You could also even get the trail file of the version BEFORE this currently running session by using the script above, then using ProFilenameParse to return an integer of the current version, subtracting by 1, and rebuilding the path to that previous version.

-----------------

EDIT:

A better method would be to actually read the configuration setting "trail_dir" using ProConfigoptGet(), and use that to feed directly into ProFilesList(). Forgot that option existed

As a side note, I'd try to stay away from Trail files as much as possible considering they aren't garunteed to be the same between Creo builds/datecodes. I definitely agree however that something that is returning PRO_TK_GENERAL_ERROR for more than one situation should be given a little more detail from PTC's end, so that the toolkit programmer can create better error handling. I think a more appropriate suggestion would be to request that the function in-question return a different error (perhaps "PRO_TK_UNSUPPORTED" or "PRO_TK_DWGCREATE_ERRORS"?) when dealing with a DRW as you described.

Newbie

Hello James,

Thanks for the pointers. Much appreciated.

> A better method would be to actually read the configuration setting "trail_dir" using

> ProConfigoptGet(), and use that to feed directly into ProFilesList().

That's what I ended up doing. If "trail_dir" has not been set, and an empty string is passed to ProFilesList(), it will fall back on the current working directory, which is the only other possible location for the trail file. So this will give correct results without having to know the trail directory in advance.


> If you wanted to do even more verification, you could use ProFilenameParse to ensure that the

> file is named "trail.txt", as well as to get the version.

I've set the filter for ProFilesList to "trail.txt" instead of "*.txt" to narrow it down beforehand.

> As a side note, I'd try to stay away from Trail files as much as possible considering they

> aren't garunteed to be the same between Creo builds/datecodes.

Agreed. I consider poking around in a trail file a last resort.

> I think a more appropriate suggestion would be to request that the function in-question return a

> different error (perhaps "PRO_TK_UNSUPPORTED" or "PRO_TK_DWGCREATE_ERRORS"?)

> when dealing with a DRW as you described.

Indeed, these are the topics of support requests with PTC API Support.

But I though getting the trail file name in 1 function call would always come in handy.

Thanks again for your help.

Regards,

  Frank



Community Manager
Status changed to: Archived