Skip to main content

Transferring of variables between Python and IDEAScript

Does anyone know if it is possible to send variables generated in a python script to be used in an IDEAScript? I've got an existing Python script that converts an XML-file into a CSV-file using the pandas module that is called from an IDEAScript using .runpython module in IDEA10.4. However there are also several built-in checks to ensure the completeness and accuracy of the information as well as the location where the file is saved which is stored in variables within the Python script. Is it possible to send these variables with their values to the IDEAScript that calls the Python script to perform these checks within IDEA? Or is this not possible and should I export these values in a textfile and then import this new file into IDEA to use the values of the variables? 

Brian Element Sun, 12/20/2020 - 10:32

Your only option is the Client.RunIDEAScriptRV.  It only allows for 4 variables.  If you need more then you will have to transfer it through a text file. Below is from the language browser.


Run another IDEAScript macro and return four variables to the caller. In order for values to be returned, the called macro must assign the values back to the global constants arg1, arg2, arg3, and arg4, respectively.


Client.RunIDEAScriptRV(scriptName As String, arg1 As Variant, arg2 As Variant, arg3 As Variant, arg4 As Variant )


[in] scriptName

The macro to be executed.

[in/out] arg1

First parameter, which is also used as a return value.

[in/out] arg2

Second parameter, which is also used as a return value.

[in/out] arg3

Third parameter, which is also used as a return value.

[in/out] arg4

Fourth parameter, which is also used as a return value.

Return Value



Control always returns to the next step of the calling macro when the called macro finishes executing.

If the full path of the file is not specified and only the file name is specified, IDEA limits its search to the root folder of the active project.

If the macro resides in a sub-folder in the active project, you must specify the sub-folder name. For example, Client.RunIDEAScriptEX "Temp\MyScript.ISS", "Hello", "", "", "".




Sub Main

' Create input values for an IDEAScript macro.

Arg1 = "Hello"

Arg2 = "Goodbye"

Arg3 = "Blue"

Arg4 = "Green"

' Start another IDEAScript macro.

Client.RunIDEAScriptRV "MyScript.ISS", Arg1, Arg2, Arg3, Arg4

' Display the return values.

MsgBox "The return values are: " & Chr(13) & _

Arg1 & Chr(13) & Arg2 & Chr(13) & _

Arg3 & Chr(13) & Arg4

End Sub

BVisser Sun, 12/20/2020 - 14:48

Hi Brian, Thank you for the quick response. I will use a text file then. Thanks for all of the effort you put in this site, it is amazing and greatly appreciated.

jsandoval Mon, 03/01/2021 - 11:01

I have a similar doubt.  I need to send a variable to python but I'm not sure how. I think that I can do it by using  Client.RunPythonEx but I don't know how to use it or whether there is a code that I need to write in python to accept the variable from IDEA.
Can anyone help me with this?

Brian Element Tue, 03/02/2021 - 10:19

In reply to by jsandoval

Hi jsandoval,

When you install IDEA there is some sample code on exactly how to do this.  If you look in your sample folder under macros: C:\Users\\Documents\My IDEA Documents\IDEA Projects\Samples\Macros.ILB you will see the following files:

ShowMedian.iss and

The ShowMedian.iss calls the and sends several items to the python script for use by the script.  Hopefully this will make it clear on how to do this, if not come back and let me know.

Good luck.

jsandoval Wed, 03/03/2021 - 09:28

In reply to by Brian Element

Hi Bryant, thank you for the quick response.
I've been trying using the function with the example you told me but I still can't make it to work. What I want to do is to declare a variable in IDEA, and then pass that variable to Python to make something with it. But python give me an error because the variable is not declared, wich means that Client.RunPythonEx is not working properly. Could you please tell me what is wrong with my code? I know it must be something silly but I can't figure it out.
Sub Main
    Dim test As String
    Dim data(0) As Variant
    test = "This is a test"
    data(0) = test
    Client.RunPythonEx "D:\jsandoval\Downloads\", data
End Sub