Hello everyone, I have a custom library written in C#. I loaded the DLL file of that library into my Python script, and it works fine. However, it doesn’t suggest methods and properties, such as when I use classes from the Revit API (as shown in the image below). How can I achieve the same functionality?
Hi @sanzoghenzo , Could you guide me on how to accomplish this step by step? I tried using Generate API Stubs and selecting the folder containing my custom DLL library file, but this is the result I got. I’m not sure if I did it correctly.
hi @sanzoghenzo ,sorry for misunderstanding your point. I have created a stub with the help of ChatGPT. Below is the link to my stub file. However, even after adding the file path of the stub as shown in the image, there was no change. Regarding adding it to clr, I tried as shown in the image, but it still didn’t work. Can you help me?
Please have a look at ironpython documentation on this topic, especially the last part of this section
You can load assemblies that are neither in the GAC nor in the appbase (typically, the folder of ipy.exe or your host appplication executable) either by using clr.AddReferenceToFileAndPath or by setting sys.path
@sanzoghenzo, now I understand that a stub file is just a file we add to VSCode to provide the code suggestions. Besides that, we still need to add the DLL file to the CLR to use all the methods and properties in it by:
clr.AddReference(dll_path)
And as @Jean-Marc mentioned, I need to restart VSCode to see the stub files suggesting code. Thank you both very much!