scripting:tool

No renderer 'pdf' found for mode 'pdf'

Tool Script

Add Tool ScriptTool script, is a just a script that does not register any events (callbacks) and exists immediately after execution.

If you have written tool script you can call it directly using Tools→Execute or you can plug it into UI same way as you do for external tools.

If plugging it as an external tool, everything is straight forward:

  1. In Manage Tools dialog you create new tool.
  2. In tool properties select as command path to your tool script.
  3. Add some icon, give nice title etc
  4. Add arguments (not really needed, while script can access all variables with scripting, but implemented for convenience)
  5. Assign shortcut, if you want one
  6. Catch Output is by default On because if you write in Output with tool, it automatically caught by HippoEDIT
  7. Select where you want to see your tool: in Tools menu, in Context menu, in Tools toolbar
  8. Done.

The tool script below will write script arguments and selected text from current view into Output pane:

tool.js
#include "he_utils.js" // from here ax2js comes
#include "he_edit.hejs" // and from here GetSelectedText helper
 
var arguments = ax2js(ScriptArguments);
Output().write(ScriptName + " is executed with arguments : ");
 
for (i = 0; i < arguments.length; i++)
	Output().write(arguments[i] + " ");
 
Output().writeln(); // insert line break after last command line parameter
 
if ( ActiveDocument != null )
{
	Output().writeln(ActiveDocument.Path);
	Output().writeln(GetSelectedText(ActiveDocument.ActiveView));
}

The output:

C:\temp\tool.js is executed with arguments : C:\temp\tool.js 
C:\temp\tool.js
ActiveDocument != null

Which looks in the editor like this:
Tool Script and its output