Determine the path (location) of a .pet file (Petrel project file) via the Ocean API?

383 views Asked by At

Within a Petrel plugin, I wish to determine the location of the current project's .pet file, if it has one. Is there an Ocean API call I can use to get this information?

2

There are 2 answers

1
Keith On

Look at PetrelProject.GetProjectInfo( IDataSourceManager dataSourceManager ). It returns an IProjectInfo which has the information you are seeking.

0
DimaTX On

Please note the remarks for IProjectInfo.ProjectStorageDirectory:

"Do not create files using the storage directory! Petrel deletes all files not belonging to the project on project save. Use OpenCompressedStream(String, FileAccess) / OpenStream(String, FileAccess) instead, which places the file where it will not be deleted during project save. During project Save As, the storage directory will be in the new project location."

Though it is not officially documented, streamName can be a relative path (e.g., "MyyPlugin\MyData.xml"). Petrel will created a directory for your file (%PROJECTDIR%\Ocean\MyyPlugin\MyData.xml in this case)