Skip to content

BeforeFileOpen

Called after a project file is loaded, before the user works with it. The plugin may veto the open or ask the host to drop variables.

When is this called?

Called only when beforeFileOpen is advertised. If the plugin returns null or an error, the open continues (allowOpen=true) so the user is never trapped. removeVariables are deleted in memory only; the file on disk is not rewritten and the document is not marked modified. If allowOpen is false, the host discards the loaded document without a save prompt, without BeforeFileClose, and without adding it to Recent. Not called during HydroSym command-line PDF export. Host.OpenProject uses the same load path, so a plugin that opens files from an external system should not prompt again here.

Capability: beforeFileOpen

C# Override

public override BeforeFileOpenResponse? BeforeFileOpen(BeforeFileOpenRequest request)
{
    return new BeforeFileOpenResponse { AllowOpen = true };
}

Request

Field Type Required Description
projectPath string ✅ Full path to the project file that was just loaded.
parentWindowHandle integer ✅ HWND for modal plugin dialogs.
variables map ✅ Current project variables (HydroSym AttributeList / HydroMan UserVarList).

Response

Field Type Required Description
allowOpen boolean ✅ false discards the just-loaded document. true keeps it open.
removeVariables array<string> Variable keys to delete in memory without saving the file.

JSON

The SDK serializes these JSON bodies for you.

{
  "projectPath": "C:\\Projects\\block.mnf",
  "parentWindowHandle": 0,
  "variables": {"CustomerName": "Example Corp"}
}
{
  "allowOpen": true,
  "removeVariables": []
}

JSON Schemas: Request · Response