Add .dll reference to get the Intellisense

#22

We are talking about Revit API libraries so Dynamo developers can’t do anything about this. Also, there is nothing wrong with a DLL containing a lot of stuff, so I am not sure i would want to bother anyone with this anyways.

The “running out of memory” is not a problem with the DLL, but with pyCharm or Atom. Each of these IDEs has a number allocated for how much stuff it keeps in memory when dealing with AutoComplete. @Gui_Talarico hints at that in his instructions on how to get his solution installed. pyCharm does the same thing. By default it’s set to 2GB and that is not nearly enough to get RevitAPI and RevitAPIUI stubs loaded and good to go. Problem is that even with that number cranked to 10GB it will not handle the whole thing, and that goes back again to what @Gui_Talarico hinted at with Jedi just being a massing resource hog. He also suggested that instead of trying to crawl the whole library we should perhaps use truncated stubs and save our computer resources.

@Thomas_Mahon yes, it’s verified. I am running auto completion in pyCharm for RevitAPI, Revit APIUI and all other Dynamo libraries. It uses the same method that @Gui_Talarico posted - generator3 to create stubs, then load them into pyCharm - but since it’s a little finicky I wasn’t planning on posting it until i figure out a sure fire way to make it work every time. Also, I am on a pyCharm pro, and haven’t gotten it to work on the free version yet, so that’s part of the issue as well. I need to figure out if there is a correlation between that.

0 Likes

#23

@Mostafa_El_Ayoubi, no not yet. @Kulkul has suggested “Sublime Text” and that looks also interesting.

I had an idea that since it is a MS$ tool and in the VS range, I would imagine that I could transfer things and knowledge between the VS and VSC platform, but that doesnt unfortunately seem to be the case.

0 Likes

#24

@Mostafa_El_Ayoubi - do you know if it’s possible to reference something like the Revit API.dll in a pycharm project, so you can get code completion features?

1 Like

#25

I’m trying with Microsoft Visual Studio and an IronPython Application, but is not possible to use de RevitAPI and/or RevitAPIUI references. The Solution Explorer display something like an error/alert icon.

Any idea?

0 Likes

#26

The post has become messy somehow… Before post 6 and after post 8 is correct.
Post 25 should be in between post 6 and 7. Post 23 and 24 should have been in between post 7 and 8.

The correct order for post is…






0 Likes

#27

SOLUTION - PART 2… here is the explanation how to do it :slight_smile:
I have marked @Gui_Talarico as giving the solution. Since this thread came from the Python IDE post concerning lightweight IDE environment especially VSCode and not issues concerning Visual Studio…


Just to follow up… I have got a solution and a special thanks go to @Gui_Talarico and @Kulkul
Step by step guide -> https://www.useloom.com/share/72588e78e6cc4d65a8a294b84ed2dee1

The essense of making @Gui_Talarico stubs running ( Add .dll reference to get the Intellisense ) is that IronPython doesnt support the solution!

You need to install “native” Python ( https://www.python.org/downloads/release/python-2713/ )
I took the 2.7.13 version, but the 3.6 version should work also…

My settings in VSCode ended up like this:

    //Python
    "python.linting.enabled": false,
    "python.linting.pep8Enabled": false,
    "python.pythonPath": "C:\\Program Files\\Python27\\python.exe",
    "python.autoComplete.extraPaths": ["C:\\Users\\erfajo\\.vscode\\stubs.min"],
    "python.autoComplete.preloadModules": [
        "Autodesk.Revit.DB",
        "Autodesk.Revit.UI"
    ] 

The important part is the “python.pythonPath” and “python.autoComplete.extraPaths”. The rest of it I copied from @Gui_Talarico while he had that in his settings… they should not be needed :slight_smile:

Thats that… so simple… but only if you are a real good coder you would figure that IronPython didnt support the solution… I would never have guessed that, so thanks a lot to both @Gui_Talarico and @Kulkul

6 Likes

Python autocomplete?
Accessing all of an elements properties in a python node
Flipped objects - help required with Python
Splitting topics and locking is poorly administered
Intellisense step by step configuration on visual studio code
Install Python library without pip
opened #29
0 Likes

#30

Here’s what I have for pyCharm:

7 Likes

#31

Hi @Konrad_K_Sobon

This is really awsome, thank you for sharing!
Do you know if it’s necessary to copy the stubs into the Binary Skeletons folder with each new project?

i can see that the folder gets reset whenever creating a new project, mabye you know a way to make the folder a standard you can use on every project?

0 Likes

#32

Interesting. I thought these were specific to the Interpreter that you are using. So if you create a new project and use the same IronPython interpreter that should point at the same binary library. Only when you switch to a different interpreter it creates a new folder location for binary skeletons.

0 Likes

#33

Does your solution work for the community edition as well?

0 Likes

#34

It was tested on Community Edition. Bear in mind that this is not ideal. I would give it a try, but .NET libraries are notoriously not well integrated with Python so this might be a superficial fix/help.

1 Like

#35

Hi all, thanks for all the info on this, but for some reason it’s not working for me and I have no idea why:

For vscode I have already:

  • Installed python extension
  • Download ironpython stubs (made sure files were unblocked)
  • Amended settings as per @Gui_Talarico’s settings

I’m not sure why the intellisense isn’t working, I know this has already been discussed, but if anyone can spot something I’ve done wrong I really would appreciate it:

{
"python.linting.pylintEnabled": false,
"python.linting.enabled": false,
"python.linting.pep8Enabled": false,
"python.pythonPath": "C:\\Program Files\\Anaconda3\\python.exe",
///"python.pythonPath": "C:\\Program Files (x86)\\Python\\Python36-32\\python.exe",
"python.autoComplete.extraPaths": [
    "C:\\Users\tpovey\\.vscode\\ironpython-stubs-master\\stubs.min"],
"python.autoComplete.preloadModules": [
    "Autodesk.Revit.DB",
    "Autodesk.Revit.UI"
]

}

Cheers,

TJ

0 Likes

#36

Hi @Tom_James

Copy Python2.7 to C:\Python27 folder location and download the ironpython stubs in C:\Test folder. Finally Copy these settings in the VSC:

{
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": false,
"python.pythonPath": "C:\\Python27\\python.exe",
"python.autoComplete.extraPaths": [
    "C:\\Test\\stubs.min",
    "C:\\Test\\revitpythonwrapper.min"
    ]
}

Here is the process in action:

4 Likes

#37

Thanks @Kulkul you’re a star, not sure why it worked as I just moved everything from the paths above directly to my C drive. Too long a path maybe?

Works anyway, thanks very much,

TJ

0 Likes

#38

@Tom_James
The problem is not the stubs files, mine are located [ “user”\.vscode\stubs.min ] and mine works perfectly.
The python installation is problem. Placing that somewhere else than what is suggested will give you trouble. I did the exact same mistake initially :slight_smile:
Meaning “python.pythonPath”: “C:\Python27\python.exe” is mandatory somehow if you dont want to do a lot of editing :slight_smile:
By the way, dont use Python 3.6 since it is syntactically different than Python 2.7
AND install x64 bit version!

0 Likes

#39

Hi guys.
I was trying Konrad’s tutorial on how to get the autocomplete in pycharm and, I was just wondering what you guys mean by stubs?
What is it exactly that I should copy into the folder and where do I get it? I get the feeling that it’s not the DLLs themselves since the stubs folder doesn’t contain any DLLs.

0 Likes

#40

you can find the stubs here

as written by @Konrad_K_Sobon in this post

0 Likes

#41

I have struggled to create Python Code for Dynamo Nodes using the RevitAPI with Visual Studio Community 2015 and Sublime, but it seems it works now with Visual Studio Code. So I have created 2 small tutorials:

How to install Visual Studio Code to Create Python Code with Autocomplete/Intellisense [including the RevitAPI.dll]:

  1. download the stubs from https://github.com/gtalarico/ironpython-stubs :

  1. unblock the zip file after download:
    a) right click on the zip file, properties:
    2
    b) unblock the file:

  2. extract to a folder of your choice on your computer (eg. with WinRar) - recommend is into C:\Test:

  3. Install Python 2.7.14 64bit (recommend to the path C:\Python27): https://www.python.org/downloads/windows/ https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi

[info: Dynamo us using IronPython, but it seems that IronPython is not supporting the Autocomplete function, because of this we use Python2.7.14 to create the Python Code we use later in the Python Node in Dynamo]

  1. Install the software Visual Studio Code: https://code.visualstudio.com/download
    [further details to Visual Studio Code: https://code.visualstudio.com/docs/languages/python & https://code.visualstudio.com/docs/python/settings-reference ]

  2. Open Visual Studio Code and install these Extensions by using the search bar at the top (Erweiterungen [in german]) :
    [further details: https://github.com/Microsoft/vscode-python ]
    5

  3. To open the user settings use the keyboard combination CTRL + , [in german: STRG + ,]
    Add the following lines to the user settings and adjust the path to your stubs.min folder and your python.exe file:

    {
    “python.linting.enabled”: false,
    “python.linting.pep8Enabled”: false,
    “python.autoComplete.preloadModules”: [
    “Autodesk.Revit.DB”,
    “Autodesk.Revit.UI”
    ],
    “python.pythonPath”: “C:\Python27\python.exe”,
    “python.autoComplete.extraPaths”: [“C:\Test\ironpython-stubs\release\stubs.min”],
    }

  1. Save your settings and restart Visual Studio Code

*How to explore .dll libraries in Microsoft Visual Studio Community 2015:

[The result of this is similar to revitAPIdocs.com to explore the Revit API, but offline]

Install Microsoft Visual Studio Community Edition 2015… (not further described in this tutorial, use google)

Open the object browser in Visual Studio Community ( Menu: View -> Object Browser )

7a

Create a Custom Component Set:

7

Add the dll libraries you want to explore:

8

for example you can add to the object browser:

• ProtoGeometry.dll ( C:\Program Files\Dynamo\Dynamo Core\1.3\ProtoGeometry.dll )
• DynamoServices.dll ( C:\Program Files\Dynamo\Dynamo Core\1.3\DynamoServices.dll )
• RevitNodes.dll ( C:\Program Files\Dynamo\Dynamo Revit\1.3\Revit_2018\RevitNodes.dll )
• RevitAPI.dll ( C:\Program Files\Autodesk\Revit 2018\RevitAPI.dll )
• RevitServices.dll ( C:\Program Files\Dynamo\Dynamo Revit\1.3\Revit_2018\RevitServices.dll )
• DynamoRevitDS.dll ( C:\Program Files\Dynamo\Dynamo Revit\1.3\Revit_2018\DynamoRevitDS.dll )

5 Likes

#42

Hi,
is the setting compatible with the python 3.6? I did the steps in vscode but I get some errors. I don’t know if it is for the python version I am currently using(v3.6).

0 Likes