Using IronPython to call a script in TIBCO Spotfire®
Last updated:
8:02am Jun 13, 2018


Often it is useful to be able to call one IronPython script from another. For example, you may define some useful utility scripts that are used in multiple places in other scripts. 

Call Script

The below script uses the ScriptManager to look up a script by name. The parameters are then defined and the script is executed.

# Copyright © 2017. TIBCO Software Inc.
# Licensed under TIBCO BSD-style license.

#Example on how to call a script

from System.Collections.Generic import Dictionary
from Spotfire.Dxp.Application.Scripting import ScriptDefinition
import clr

# Get a reference to the script
# Note: this is an interesting example of how
# to use an OUT parameter in IronPython
# - the out parameter is the scriptDef
# - an "empty" variable is created by using 
# the clr (Common Language Runtime) to generate
# a reference to a ScriptDefinition object

scriptDef = clr.Reference[ScriptDefinition]()
Document.ScriptManager.TryGetScript("Name of Script", scriptDef)

# Defines the values of the parameters

paramDict = {"MyParam":"Value1", 

params = Dictionary[str, object](paramDict)

Document.ScriptManager.ExecuteScript(scriptDef.ScriptCode, params)


License:  TIBCO BSD-Style License