Jump to content
We've recently updated our Privacy Statement, available here. ×
  • How to develop IronPython scripts in Spotfire® and their limitations

    Scripts are small IronPython code snippets that can be written and executed on the fly. They require no compilation and deployment.


    Scripts are small IronPython code snippets that can be written and executed on the fly. They require no compilation and deployment. During run time, they access both Python, .NET and Spotfire libraries. Scripts are intended to perform automation tasks and are a part of the loaded Spotfire Document (DXP). Each analysis can have its own set of scripts, and like other parts of the analysis, must be manually transferred between different files if needed. Certain Spotfire libraries can not be used in the script scope since they require specific run time components. Another thing to consider is that scripts are platform independent and can not use any Windows specific GUI components such as MessageBox if they are intended to run on the Web Player or in the cloud.


    We recommend only using .NET and Spotfire libraries. This also makes converting between the Spotfire extensions and IronPython scripts later on easier.


    Scripts are executed in isolation from the rest of the running Spotfire code. This is to ensure that faulty scripts cannot crash the running client and also provide security to avoid malicious scripts. To provide further security, scripts must also be trusted before they are used. Spotfire use a undo/redo system to give the user the option to revert the changes done after the script has executed.

    It's not straightforward to import other Python packages into an IronPython script, if it is even possible.

    IronPython Scripts cannot modify the core functionality of Spotfire. The only purpose of an IronPython script is to automate Spotfire.


    To allow Spotfire control over script executions, all scripts are wrapped in a transaction. This transaction makes all actions performed in the script undoable. This has however certain drawbacks. For the transaction to work, all individual modifications done in the script will be compressed and applied in a single step when the script is finished. This sometimes affect objects modified in the script. Changing a property for instance might require the plot to recalculate before the action is done. When the script finished, all actions on the document is performed.

    Examples of IronPython compared to C#

    # Import Spotfire libraries
    # C# => using Spotfire.Dxp.Application.Visuals.TablePlot;
    from Spotfire.Dxp.Application.Visuals import TablePlot
    # Using Microsoft libraries
    import clr
    from Windows.System.Forms import MessageBox
    # Type identifiers
    # C# => TablePlot tableplot = myvis.As<TablePlot>()
    tableplot = myvis.As[TablePlot]()


    The Spotfire editor provides some basic features to aid debugging scripts (e.g. use the Print statement to output values), but does not support syntax checking or autocomplete. It is possible (although not trivial) to use an external editor to edit complex scripts - see How to use an external editor to edit IronPython scripts - with autocomplete and syntax checking for more information


    User Feedback

    Recommended Comments

    There are no comments to display.

  • Create New...