Suggest methods in custom DLL library

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?

What I got
image

What I want

1 Like

Hi @Luffy11,
You can copy the code behind the Stubs generator from the pyRevit Dev tab
And specify your assembly instead of the autodesk ones.
Then you have to add the generated stubs to vscode like you did for revit stubs

1 Like

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.

Read my message again: I wrote “copy the code” , not “run the code” :wink:

You need to build your own script to point to the dll (by changing the ASSMS list)
you also have to add it to the clr as you have done in your script

Keep in mind that I have never done this myselfso there’s maybe some other things do adjust

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?


@Luffy11 sometimes it takes a restart of your code editor.

1 Like

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

1 Like

@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!