Call Sequences¶
HydroMan calls your plugin during file open, file close, and menu clicks. Optional methods run only when their capability is advertised. HydroMan has no command-line mode; the plugin is loaded only by the GUI.
Opening a manifold¶
sequenceDiagram
participant HM as HydroMan
participant P as Plugin
Note over HM: User opens block.mnf; file is parsed
Note over HM: BeforeFileOpen only if beforeFileOpen advertised
HM->>P: BeforeFileOpen({projectPath, parentWindowHandle, variables})
P-->>HM: {allowOpen, removeVariables}
alt allowOpen is false
Note over HM: Discard the document; no save prompt, no BeforeFileClose, no Recent entry
else allowOpen
Note over HM: Delete removeVariables from the UserVarList in memory
end
HM->>P: GetMenuItemState({menuItemIds, context})
P-->>HM: {states: {...}}
Triggered by File > Open, drag and drop, the recent list, a file on the command line at startup, and Host.OpenProject. The hook runs only for an existing, non-empty file. HydroMan does not call plugin GetProjectVariables or GetFileStatus.
BeforeFileOpen: the manifold is already loaded when this runs.variablesis the current UserVarList.AllowOpen = falsediscards the document silently.RemoveVariablesdeletes keys in memory only; the file is not rewritten and the document is not marked modified.GetMenuItemState: at the end of every open attempt, including a vetoed one. Also at load, after close, before any main-window menu shows, when the plugin menu is clicked, and after each menu action.
If you open from an external system with Host.OpenProject, do not prompt again in BeforeFileOpen; the host already loaded the file.
Errors: BeforeFileOpen fails open (allowOpen=true) and the open continues.
User clicks a menu item¶
sequenceDiagram
participant User as User
participant HM as HydroMan
participant P as Plugin
User->>HM: Click Search...
HM->>P: OnMenuAction({menuItemId: "my-search", parentWindowHandle, context})
P->>HM: Host.ShowMessage("Hello from MyPlugin")
HM->>P: GetMenuItemState({menuItemIds, context})
P-->>HM: {states: {...}}
OnMenuAction returns void. Use Host API methods inside the handler for side effects. See Host API. HydroMan refreshes the menu states after the action completes.
If the handler throws, the user sees an error dialog with Plugin error: [OnMenuAction] <message>.
Closing a manifold¶
sequenceDiagram
participant HM as HydroMan
participant P as Plugin
Note over HM: User closes the manifold (also on Close All and application exit)
Note over HM: BeforeFileClose only if beforeFileClose advertised
HM->>P: BeforeFileClose({projectPath, isModified, parentWindowHandle})
P-->>HM: {allowClose}
alt allowClose
Note over HM: Native "Save changes?" prompt
Note over HM: SetProjectVariables only if setProjectVariables advertised
HM->>P: SetProjectVariables({projectPath, variables: {}})
P-->>HM: {} (OK)
HM->>P: GetMenuItemState({menuItemIds, context})
else veto
Note over HM: Close cancelled
end
BeforeFileClose runs before the native save prompt; the user can still cancel there, so do not release locks yet. SetProjectVariables runs only after the close is confirmed.
SetProjectVariables.variables is always an empty map; HydroMan does not push UserVarList values on close. Use projectPath to identify the PDM or ERP item to check in or unlock. Neither hook fires for a manifold that has never been saved.
On application exit, every open manifold goes through this sequence before the plugin's Finalize is called.
Errors: BeforeFileClose fails open (allowClose=true) and the native close prompt follows. A SetProjectVariables error is logged; the file still closes.
Export PDF via menu¶
sequenceDiagram
participant User as User
participant HM as HydroMan
participant P as Plugin
User->>HM: Click a plugin menu item
HM->>P: OnMenuAction({menuItemId})
P->>HM: Host.ExportPdf({filePath, projectPath})
HM-->>P: {filePath, pageCount}
Note over P: Upload PDF to vault or ERP
P->>HM: Host.ShowMessage("PDF exported")
PDF export is always plugin-initiated through Host.ExportPdf. It merges all production layouts into one PDF and excludes assembly layouts. A manifold without a production layout fails with EXPORT_FAILED.
- Omit
filePathto write next to the manifold with the same base name. This needs a saved manifold; otherwise HydroMan raisesNO_OUTPUT_PATH. - Omit
projectPathto target the active manifold.
Map projectPath to your ERP or PDM project identifier in the plugin. GetCurrentProject.projectId is always empty in API v1.