Hi there,
I would be looking at how you can select and save automatically a specific foil file using the Javascript API / CLI.
I am currently running automated Gomboc runs via the Batch mode external connection to explore simulations with different foil geometries defined with parameters through a javascript file. At the end of the js file which modify the foil geometry + launch the simulation + do some other operations, I would like to quite Gomboc nicely with Host.quit(); . Gomboc however shows the graphic confirmation window to confirm if I want to close without saving the newly modified foil (which are showing a start in their name).
I have been looking at the functions available via:
- query(Host)
- query(Host.foilHolder())
- This reveals the Host.foilHolder().foilSave() and Host.foilHolder.foilSaveAs()
- query(Host.foilHolder().foilDefinition(N)), N being the index of the foil on the list.
When doing a few tests:
- Host.foilHolder().foilSaveAs() opens the GUI window for saving the foil file so requires manual interaction and cannot be automated.
- Host.foilHolder().foilSave() seems to save the foil at the root of the Gomboc RUNTIME_PATH. I tried Host.foilHolder().foilSave(path\filename.foil) and it does not seem to save in a specific location under a specific file name. However this solution would save the foil, but this is only for the foil selected by default in the foil holder which is the top one.
In my case, the foil that needs to be saved as is (because it was modified and shows the *) is not the first (top one) foil on the foilHolder interface and I would be looking at selecting a specific foil to be able to save it. query(Host.foilHolder().foilDefinition(N)) does not seem to showcase a select or save function appart from the one mentioned above.
At the moment, I force the Gomboc closure by using taskkill /f /im Gomboc.exe at the end of the bat file launching the Gomboc session, however this is a risky approach when trying to run several runs in parallel (as this could kill any of the Gomboc session in progress).
Another way to maybe tackle the issue would be to have an option in the General Gomboc settings that would allow to close Gomboc with an unsaved modified foil without asking for user confirmation. Users could activate or deactivate this feature according to their preferences.
I also still observe some fail to launch Gomboc via bat file behavior as sometime the Gomboc.exe goes in the background process and does not show the GUI and does not seem to run the script.
Thank you for your help,
Nicolas
Hi Nicolas,
Thanks for your question. You are correct, with the current methods available in Gomboc, it is not really possible to quit the application from a script if there are some unsaved foils in the foil holder. Your suggestions are also very interesting and we have implemented these following methods which should help you to achieve your needs:
foilSaveActiveAsFilePath(string pathName)
. It saves the active foil geometry*.foil
file at the location specified inpathName
.
Example:foilHolder().foilSaveActiveAsFilePath("C:/gomboc-sdk/foil.foil")
forceQuit()
. This forces the Gomboc application to close, even if there are dirty foils or running simulation in progress.
Example:Host.forceQuit();
setActiveSlot(string slotName)
. This allows to select the active slot in the foil holder from the slot name string.
Example:foilHolder().setActiveSlot("Boat.Port.Rudder")
These new methods will be available in the next Gomboc release. In the meantime, we will make sure to provide you with a beta release upon request.
Finally, please note that a clearDirty()
method of the FoilDefinition class is available in the current Gomboc release. IT does a force clean on the foil in the foilHolder and removes unsaved versions of a foil.
Example: Host.foilHolder().foilDefinition("Boat.Port.Keel").clearDirty();