gtalarico / ironpython-stubs

Autocomplete stubs for common IronPython/.NET libraries
Other
249 stars 80 forks source link

Missing Revit Methods in VS Code and missing Revit Services and Transactions #29

Open DwayneAcosta opened 2 years ago

DwayneAcosta commented 2 years ago

Hi!

I have installed the iron stubs against Python v2.7.18 and have edited the settings.json file of Pylance to include extra paths as instructed with linting disabled.

I have intellisense for the basic imports and a few first level codes such as FilteredElementCollector, however, when I do FilteredElementCollector(doc). - after the "." nothing comes out. This is also the same for element.Category for example, nothing comes out as well.

I'd like to ask if this is the case or is there an error somewhere in my set up.

Appreciate the help. Thanks! :D image

PavelAltynnikov commented 2 years ago

This is a stub problem. To make it work, you need to go into the code of the stubs, in this case, in the FilteredElementCollector and replace the methods pass with return salf. But only for those methods that return a FilteredElementCollector

DwayneAcosta commented 2 years ago

Hi Pavel, thanks for the help.

I tried going over to FilteredElementCollector.py in stubs.min and changed the .WherePasses method to return self but doesn't work.

However I noticed a new problem and that there are codes in each of the python files that are missing, see below. This problem also persists in a lot of the other python codes in the stubs.min file.

Is this because I downloaded the wrong stub.min file? I actually just downloaded the entire folder in this github page and used what's there.

Thanks again

image

PavelAltynnikov commented 2 years ago

I don't even know how else to help. Try these stubs, I generated them not so long ago and it seems that in our community they all work with Pylance. Be sure to read the readme and examples

DwayneAcosta commented 2 years ago

Hi Pavel,

It finally works, thank you! So it was the stubs after all. If you don't mind, can I ask how you generated the stubs yourself? or perhaps a reference guide that I can read?

Also I noticed that the stub file you sent were divided into sub-folders having different years, are these Revit versions? or are these when the stubs were generated?

Thanks again!

image

PavelAltynnikov commented 2 years ago

I reworked the gtalarico project a bit, but for the most part the essence remains the same. Yes, the stubs are separated by Revit versions, in my repository in the readme there are instructions on how to work with them.

DwayneAcosta commented 2 years ago

Thanks Pavel. Apologies it took me a while to get back to you.

Appreciate the help!

toothless92 commented 1 year ago

Leaving this for others that may find it useful, I have made a script to fix typing issues, see here: https://github.com/gtalarico/ironpython-stubs/pull/35