0

I am having an issue importing a .dll library in Python 3.11.

For IronPython, the import is successfull and looks as follows (example is for using the API of a structural analysis package called Robot from Autodesk):

import clr
clr.AddReferenceAndFilePath('C:\Program Files\Autodesk\Robot Structural Analysis Professional 2023\Exe\Interop.RobotOM.dll')
import RobotOM as rbt
print(dir(rbt))

And the output is a comprehensive list of all members functions, methods and attributes of the library:

['DontUseIt', 'DontUseItClass', 'IDontUseIt', 'IRBestBendType', 'IRBestCalcErrors', 'IRBestCalcParamsData',  ...]

Following a similar syntactical approach in Python 3.11, I was expecting the same results as that of IronPython:

import ctypes
RobotOM = ctypes.WinDLL(r'C:\Program Files\Autodesk\Robot Structural Analysis Professional 2023\Exe\Interop.RobotOM.dll')
print(dir(RobotOM))

The output is as follows:

['_FuncPtr', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_flags_', '_func_restype_', '_handle', '_name']

Various other approaches yield the same results, such as:

import ctypes
RobotOM = ctypes.cdll.LoadLibrary(r'C:\Program Files\Autodesk\Robot Structural Analysis Professional 2023\Exe\Interop.RobotOM.dll')

My question: how can I replicate the successfull import of the .dll library in Python 3.11? With IronPython it is possible, surely the same should be possible for Python 3.11?

2
  • Everything works as expected. On one hand you have .NET and on the other C. To mimic IronPython behavior, you should install some .NET .dll handler package (if available - github.com/pythonnet/pythonnet ?). Commented Oct 7, 2023 at 22:48
  • Does this answer your question? How to load a C# dll in python? Commented Oct 7, 2023 at 22:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.