RhinoPython is a plugin to allow you to code Rhino python script in VS Code editor and run it in Rhino runtime. It inherits all the autocomplete intelligence from original rhinopython editor and can react faster, while you can benifit all the amazing advatanges that VS Code brings to you.
It is a DesignToProduction open source project, programmed initially for internal use.
From v0.1.7, it supports both Rhino 5 and Rhino 6, with correct build being installed.
:star: If you prefer to code in Visual Studio, RhinoPythonForVS is a lot faster and provides much better IntelliSense. Give it a try!
The same way as you use the original editor. Just more efficient, simpler and faster.
Check this youtube video to see more clearly of the gif shown below.
This is the client side of RhinoPython editor. To bridge it to Rhino you need a server to listen to VS Code editor, which is another plugin called CodeListener.
Install VS code.
Install python for VS code. It's recommended to familarize yourself with python for VS code at this post first.
Install RhinoPython for VS code.
Download CodeListener
file in food4rhino, and install it.
Start Rhino, click tools -> pythonscript -> edit
, in the python editor, click tools -> options
, copy those module paths. You might have additional libraries and you have to copy them as well.
In Rhino, click tools -> options -> Plug-ins -> CodeListener -> Proterties
, copy the file containing folder path and open it in the explorer. Copy the AutoComplete
folder path.
Start VS Code, open user settings
by keyboard shortcut Ctrl+,
paste the libraries paths and autocomplete path into the user settings
with key "python.autoComplete.extraPaths", below is an example setting.
If
AutoComplete
doesn't work even if you add the path intopython.autoComplete.extraPaths
, it's probably that you haven't add the root folder of the library. For instance, if your libraryExampleLib
is under folder"...\Libs"
, you might have to add"...\Libs
instead of"...\Libs\ExampleLib"
.
{
// disable certain pylint messages
"python.linting.pylintArgs": [
"--errors-only",
"--disable=E0001",
"--disable=E0401"
],
// python autocomplete extra path
"python.autoComplete.extraPaths": [
"C:\\Users\\jingcheng\\AppData\\Roaming\\McNeel\\Rhinoceros\\5.0\\Plug-ins\\CodeListener (8c4235b6-64bc-4508-9166-bef8aa151085)\\1.0.0.0\\AutoComplete",
"C:\\Users\\jingcheng\\AppData\\Roaming\\McNeel\\Rhinoceros\\5.0\\Plug-ins\\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\\settings\\lib",
"C:\\Program Files\\Rhinoceros 5 (64-bit)\\Plug-ins\\IronPython\\Lib",
"C:\\Users\\jingcheng\\AppData\\Roaming\\McNeel\\Rhinoceros\\5.0\\scripts"
],
// enable new language server. THIS IS EXTREMELY IMPORTANT TO HAVE FAST AUTOCOMPLETE!!
"python.jediEnabled": false,
// Enable/Disable rhinopython
"RhinoPython.Enabled": true,
// True if you want to reset script engine every time you send code, otherwise False
"RhinoPython.ResetAndRun": true
}
The microsoft team has implemented their own language server, which replaces the old jedi languange server. This has made autocomplete in python super fast and it is strongly recommended to enable it by
"python.jediEnabled": false
in the settings.
CodeListener
. You should see VS Code Listener Started...
.
You can add
CodeListener
into Rhino Command Lists every time Rhino starts. There are other commands in Rhino:StopCodeListener
,CodeListenerVersion
F2
or by typing command CodeSender
in Command Palette(F1
or Ctrl+Shift+P
) You should then see returned printed message or errors in Debug Console
. Depending on your RhinoPython.ResetAndRun
settings, you might reset script engine every time before you send.Ctrl + R
.The following settings can be configured under User Settings:
RhinoPython.Enabled
: Enable/Disable this RhinoPython extension.RhinoPython.ResetAndRun
: Determines if F2
(CodeSender
Command) reset the script engine every time before it executes.StopCodeListener
on the former one.The IntelliSense of RhinoCommon in VS Code is originated from ironpython-stubs. Thanks to Gui Talarico.