Skip to main content
Skip table of contents

IronPython API

Details

  • A detailed description of the API is located in the client's help folder (%client_folder%\help).
  • If you have trouble opening the file, see the hints below.
  • Another version can be found here: Iron_python_API_C39521.chm

How to

  • To access the documentation, download the file mentioned above.
  • Right-click on the file and select properties.
  • Click on Unblock and then on Apply.

Please note

  • We only support the methods listed in the appropriate IronPythonAPI.
  • Every Client function that is used via IronPython but which is not part of the official API may not work anymore after a Client update.

Various Know-how

Embedding IronPython code in a module

How to

  • Select a DA in your module
  • Insert a new DF with ID 004336 and change DF behavior to py
  • Close the DA and reopen it
  • Expand the DI and paste your code into IronPython script
  • Save and start the module
  • Add the following code at the top:

    CODE
    # coding: latin-1"
  • Code that looks like this in C#:

    CODE
    GetValue<T>()
  • Will look like this in IronPython:

    CODE
    GetValue[T]()

Note

  • Keep in mind that in C#, Visual Basic, and Visual C++ it is "String" but in Python it is "str"
  • Due to the IronPython bug, the indexers of the generic .NET collections will not work if a first access to them was not correct (for example the indexer requires int but you put a string value). So explicitly use the attribute getitem instead of [] or please make sure that indexers are used correctly.

Reload modules on local client without client restart

Information

  • In order to apply code changes without a client restart being necessary, use the following guideline.

How to

  • Insert the following code prior to the import statement of the target module:

    CODE
    sys.modules.Remove("MyModule")
  • After the statement above, place your unchanged import statement:

    CODE
    from MyModule import MyModule
  • The conditions for your AddReference-statement stays the same as before - it needs to stay prior to your import statement but it can stay before or after the statement of step 1.

Remembering data across multiple modules

  • Data can be stored somewhere in the __builtins__ dictionary
  • Unlike the server, each Client has its own IronPython interpreter, so everyone has their own copy of __builtins__

Stop

  • Do not use __builtins__ when calling server code, for example with server_execute()

Useful snippets

MethodParameterReturn valueComment
df
Returns the DF the IronPython script was executed from

Getting the value of a DI that is in the same DA as the IronPython macro:

CODE
df.DataArea.ChildrenDF[df.DataArea.Customizing.get_df_by_name(DF-Python-ID)].GetValue[T]()

Microsoft .NET Framework

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.