Skip to content

Call Sequences

HydroSym calls your plugin during file open, file close, menu clicks, and command-line PDF export. Optional methods run only when their capability is advertised.


Opening a schematic

sequenceDiagram
    participant HS as HydroSym
    participant P as Plugin

    Note over HS: User opens valve-assembly.hdf; file is parsed and FMS attributes downloaded
    Note over HS: BeforeFileOpen only if beforeFileOpen advertised
    HS->>P: BeforeFileOpen({projectPath, parentWindowHandle, variables})
    P-->>HS: {allowOpen, removeVariables}
    alt allowOpen is false
        Note over HS: Discard the document; no save prompt, no BeforeFileClose, no Recent entry
    else allowOpen
        Note over HS: Delete removeVariables from the attribute list in memory
        Note over HS: GetFileStatus only if getFileStatus advertised
        HS->>P: GetFileStatus({filePath})
        P-->>HS: {status: "checkedIn", version: 3, isManaged: true}

        Note over HS: GetProjectVariables only if getProjectVariables advertised
        HS->>P: GetProjectVariables({projectPath, projectId})
        P-->>HS: {variables: {CustomerName: "Bosch Rexroth", Revision: "C", DrawingNo: "VA-2025-0042"}}

        Note over HS: Apply variables to the attribute list
        HS->>P: GetMenuItemState({menuItemIds, context})
        P-->>HS: {states: {...}}
    end

Triggered by File > Open, drag and drop, the recent list, a file on the command line at startup, and Host.OpenProject. The hooks run only for an existing, non-empty file that loads successfully as a schematic. Symbol files and zero-byte files skip them.

  • BeforeFileOpen: the file is already parsed when this runs. variables is the current attribute list. AllowOpen = false discards the document silently. RemoveVariables deletes keys in memory only; the file is not rewritten and the document is not marked modified.
  • GetFileStatus: the result is discarded.
  • GetProjectVariables: applied to the attribute list of the schematic and of every layout, after the FMS attribute download, so your keys are what the user sees. A later print or BOM action re-syncs header attributes and can overwrite them.
  • GetMenuItemState: after the variables are applied. Also at load, after close, before a menu bar menu shows, and after each menu action.

Errors: BeforeFileOpen fails open (allowOpen=true). GetFileStatus and GetProjectVariables errors are logged and the file still opens. A GetFileStatus error skips GetProjectVariables and the menu-state refresh for that open.


Command-line PDF export

sequenceDiagram
    participant CLI as HydroSym.exe createpdf
    participant P as Plugin

    CLI->>P: GetInfo / Initialize
    Note over CLI: Load schematic in memory
    Note over CLI: GetProjectVariables only if getProjectVariables advertised
    CLI->>P: GetProjectVariables({projectPath})
    P-->>CLI: {variables: {...}}
    Note over CLI: Apply variables, then header sync (may overwrite plugin keys)
    Note over CLI: Export PDF
    CLI->>P: Finalize

Triggered by HydroSym.exe createpdf <file.hdf> [export dir], and likewise by createsinglepdf and createbomaspdf. The plugin is loaded once per process, with no main window. BeforeFileOpen is not called. The .hdf on disk is not rewritten unless your plugin calls Host.SaveFile or Host.SaveProjectAs.

Unlike GUI open, the header attribute sync runs after GetProjectVariables here, so header values can overwrite your keys on the PDF.

If the plugin is disabled, fails to load, or returns an error, the PDF is still generated and the problem is logged. There are no plugin menus in this mode, and Host.OpenProject and Host.NewProject raise NO_UI. Host.ShowMessage still opens a modal dialog and blocks the run, so avoid it when InitializeRequest.MainWindowHandle is 0. Host.SetStatusBar is a no-op.

If HydroSym is already running, a second HydroSym.exe instance does not run the command. It forwards its first argument to the running window, which ignores anything that is not an existing file path. Close the GUI before running a command-line export.


User clicks a menu item

sequenceDiagram
    participant User as User
    participant HS as HydroSym
    participant P as Plugin

    User->>HS: Click Search...
    HS->>P: OnMenuAction({menuItemId: "my-search", parentWindowHandle, context})
    P->>HS: Host.ShowMessage("Hello from MyPlugin")
    HS->>P: GetMenuItemState({menuItemIds, context})
    P-->>HS: {states: {...}}

OnMenuAction returns void. Use Host API methods inside the handler for side effects. See Host API. HydroSym refreshes the menu states after the action completes.

If the handler throws, the user sees a message box with Plugin error: [OnMenuAction] <message>.


Closing a schematic

sequenceDiagram
    participant HS as HydroSym
    participant P as Plugin

    Note over HS: User closes the schematic (also on Close All and application exit)
    Note over HS: BeforeFileClose only if beforeFileClose advertised
    HS->>P: BeforeFileClose({projectPath, isModified, parentWindowHandle})
    P-->>HS: {allowClose}
    alt allowClose
        Note over HS: Native "Save changes?" prompt, FMS check-in
        Note over HS: SetProjectVariables only if setProjectVariables advertised
        HS->>P: SetProjectVariables({projectPath, projectId: "", variables})
        P-->>HS: {} (OK)
        HS->>P: GetMenuItemState({menuItemIds, context})
    else veto
        Note over HS: 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 and receives the full attribute list as variables. Both hooks fire only for schematics.

On application exit, every open schematic goes through this sequence before the plugin's Finalize is called.

Errors: BeforeFileClose fails open (allowClose=true). A SetProjectVariables error is logged; the file still closes.


Upload BOM via menu

sequenceDiagram
    participant User as User
    participant HS as HydroSym
    participant P as Plugin

    User->>HS: Click "Upload BOM to ERP"
    HS->>P: OnMenuAction({menuItemId: "my-upload-bom"})
    P->>HS: Host.GetBom()
    HS-->>P: {items: [...]}
    Note over P: Push items to ERP
    P->>HS: Host.ShowMessage("BOM uploaded")

Map projectPath to your ERP or PDM project identifier in the plugin. GetCurrentProject.projectId is always empty in API v1.