Python version compatibility for Project and Batch APIs

The exception below (or similar) is thrown when trying to access the Project API or Batch API using Python:

FileNotFoundException: Unable to find assembly 'GH.Bladed.Api.Facades' in Python.Runtime.CLRModule.AddReference(String name)

The exception occurs after execution of the the following script line:

clr.AddReference('GH.Bladed.Api.Facades')

Cause

When using the Project API or Batch API with Python, it is important to note that only 32-bit versions of Python can be used – 64-bit versions of Python cannot be used. If the script is run using a 64-bit version of Python the error above may be shown. Note that the error message is misleading - the 'GH.Bladed.Api.Facades' file may have been found, but it cannot be loaded (i.e. due to the 32/64-bit incompatibility).

Furthermore, use of the APIs requires the Python.NET package (pythonnet), which is officially compatible up to Python 3.8.

Solution

Therefore, it is recommended that the highest version of Python that is used with the Bladed APIs is the 32-bit version of Python 3.8.


Python.NET package compatibility for Results API 1.0

The exception below is thrown within the DotNetArrayToNumpy() function in the Python implementation of Results API 1.0 (in the ResultsApiUtils.py file)

AttributeError: 'IDisposableReadOnlyList[Double]' object has no attribute 'PointerToFirstElement'

The exception occurs after execution of the the following script line:

src_ptr = dotNetArray.PointerToFirstElement.ToInt32()

Cause

This exception occurs if version 3.0.1 (or later) of the Python.NET package (pythonnet) is being used.

Solution

Downgrade the pythonnet version to 2.5.2.


Need help?

If the information above does not help to resolve your problem, please contact us for further assistance.

When contacting us, please provide all relevant details related to the problem, such as:

  • Dongle number (e.g. DT/1234) or Key ID
  • Screenshots of any error messages or other symptoms
  • Steps to reproduce the problem
  • Any relevant log files