Objective:
Databases can be exported to XYZ with the option of All or Selected line. If there are many different selections this could be time consuming and tedious. This article attempts to address the issue of many line selections for export using Oasis montaj's scripting feature.
Resolution:
- To get started make a new folder in your project folder for the workflow and copy the database you wish to export line by line into this folder
- Create a Line selection file containing all the lines that you would like to export. Assuming you are exporting all line in the database open Oasis montaj and do the following
- Open your database > Right-click the line name > Selections > Select all the lines you are looking to export
- Right-click the line name > Selections > Save selections (Please save the file name as 'all_lines', as this is the name inputted into the batch file)
- This will output a selection file which you will place in your new folder. - You will need to create a DOS Batch file (.bat) and a Geosoft script file (.gs):
-The .bat file will act as a loop to create multiple selection files (.sel) for each individual line and set them as variables in the Geosoft script. To create the .bat file copy the following text into a text editor and save as "getlines.bat".
FOR /F "tokens=*" %%A in (all_lines.sel) do @echo %%A>Line_%%A.sel
FOR /F %%i IN ('dir /b *.sel') DO "C:\Program Files\Geosoft\Desktop Applications 9\bin\oms.exe" singlelineexport.gs FILE=%%~ni
-The .gs file will be used to set the lines and export the XYZ files. To create the .gs file copy the following text into a text editor and save as "singlelineexport.gs"
CURRENT Database,".\\test.gdb"
SETINI SELGET.FILE=".\\{{file}}.sel"
GX selget.gx
SETINI EXPORT.FILE=".\\{{file}}.XYZ"
SETINI EXPORT.TEMPLATE=""
SETINI EXPORT.TEMPLATE="default.o0"
SETINI EXPORT.FILE=".\\{{file}}.XYZ"
SETINI EXPORT.TEMPLATE=".\\default.o0"
GX export.gx - Close the database in Oasis montaj
- Run the Batch file by double clicking the file. A DOS command window will pop up while the script is running. It will close when the script is complete.
The first line of the Batch will look into your "all_lines.sel" file and create individual .sel files for each line. You should see these file in the folder with the script.
The second line in the Batch will call the .gs for every .sel in the folder containing the script. You should now see .XYZ files for each of the corresponding .sel files with the line names as the filename.
Notes:
After the script has been successfully run, the excess .sel files can be deleted.