← All ideas
  • Published 24 Aug 2018

VS Code integration and out-of-the Blender DevTools - proposal

While using Unity I've found extremely useful the integration between Unity itself and Visual Studio: linter, auto completion, type hinting, all the other features given by an editor, the integration with the .NET library and the NuGet package manager

So why not porting some of those concept to Blender?

With a basic integration between Blender and VS Code, the developers would have all the benefit of a powerful editor, like:

  • Python linter
  • automatic code completion
  • Git integration and relative version control
  • Powerful and versatile debugger
  • Basically an almost complete IDE for python and, specifically, blender

VS Code would also allow the exploration of the Blender's APIs, making way faster the learning curve for people at their first encounter with these APIs

Also, with an inclusion out-of the-box of pip , the whole ecosystem of libraries for Python would become immediately usable for the possible addons, like the Tensorflow framework and the new field of machine learning, or like all the bindings with the most powerful libraries for heavy computing, like CGAL and CUDA

I propose this as feature of a normal release of Blender, or, maybe, as part of a build for developers, with a single click action to generate a VS Code project with the minimal setup to start building addons, with the PATH already configured to use Blender python CLI and all the rest of the needed boilerplate configuration

I'm sure that this would speed up considerably the development and the deploy of addons and scrips for blender, using the powerful features of the python libraries via pip and the aid of a complete IDE, other than helping in their first steps the wanna-be blender developer, accelerating even faster the growth of Blender

Do you think that this may be an useful proposal? :)

UYxw-HcD.png

100%

Development Status: Open

Upvote 19 Downvote 0
TTNK
24 Aug 2018

12 Comments

jayadevan

There is a "Blender Development" Add-On version "v0.0.17" by a person called "Jacques Lucke". That is no longer in active development (according to their own documentation). If this is what is proposed here, I wish someone senior to take this into consideration. Should I submit this as a new idea? I am a beginner, and I am not affiliated with that add-on.

Smilebags

I've recently been playing with pip in Blender and really noticing what parts could be more automated and what would make a pleasant experience.

Pip should not have to be manually installed by the user. It could be installed first time the editor is opened. When VS Code is opened in the directory created by blender, some configuration (need to look into this but looks entirely possible) needs to happen to set up VS Code's debugger, terminal etc to use Blender's Python and pip. A virtual environment seems to be the right way to go about this. If the environment is set up correctly, importing bpy should 'just work' and you'll get autocomplete and linting as expected in VS Code. I'm not too familiar with debugging in Blender, but that would be slightly more involved, as it would involve inspecting the Blender process (I think).

As a general note, almost all configuration in VS Code happens in specific named files, so setting up a workspace should be pretty simple.

alannorth

While I would like it if Blender distributed pre-built python modules (though VS Code currently has problems with them) or had some more standardized way of producing stubs for better auto-complete, I'm confused as to what exactly you're asking for in your proposal?

You can use VS Code right not just fine.

There's a Blender snippets add-on that has all of Blender's add-on templates as snippets for quickly setting up an add-on (though I prefer to keep my own template).

The only difficult thing used to be getting the debugger connected and working, which is why I wrote this Blender add-on with detailed instructions. It's still not a walk in the park, but anyone should be able to set it up now.

Also pip, etc, doesn't come with Blender's python and not sure how VS Code would change this. Or do you mean you're requesting for pip to be included with Blender?

TTNK Author

@alansartlog: That addon should be made plug and play and shipped with blender (or with a 'for-dev' build). Debugger+linter+pip+blender+[sort of] IDE and nobody can stop us :)

Sure thing is that, maybe, the comment onf @christopher.cook explains much better some of the details of my proposal, but ideally, if you ever tried coding with Unity, you know the experience I'm talking about: autocomplete, debugger configured out of the box, project files and configuration files configured out of the box, the only thing you have to do is start coding (adding on top of this the whole ecosystem given by pip)

alannorth

@pietrobelgioco: Sorry, never got far enough into unity to know.

The problem with shipping with a debugger is that, for example, the add-on I wrote uses a VS Code / VS specific debug server. There are different debuggers available. You would have to ship with multiple debuggers potentially. Also most users won't ever need them. It makes sense to keep this sort of thing add-ons imo. If pip was more easily available though (like maybe not ship with it but one click install) it would make these types of add-ons way easier to write and use.

While I would of course like more integration, the question is how exactly? You'll get more interest in your proposal if you're specific and at least list all the sub-proposals. Though it would be best to break them down into different ones if they're unrelated. For example, I don't think it exists here yet, but I've seen people in other places ask for pip support before. Then, something like the ability to set an external editor would also be nice, but is technically completely unrelated and should be a different proposal. And so on, etc. And preferably you shouldn't tie requests to any one specific software/editor.

Smilebags

@alansartlog:

I feel that solving pip installation is a managable pre-requisite for this. It really shouldn't have to be packaged in Blender, but it should be able to be executed without too much fussing around. It should be doable with a single click and there's nothing I can see that is really stopping that from happening.

My comment below explains a few of the VS-code specific details on implementing it. I don't see the concern with tying functionality to specific software, since generalising the 'external editor' functionality with debugger and all the other bells and whistles is a huge job and pretty un-maintainable. VS Code is suitable for multiple reasons, one of them being it is free and extensible. Again, it shouldn't be weighing down Blender itself, so if it isn't installed, Blender should suggest the user download it (and potentially open the download page, or have a link to it).

Smilebags

As a daily user of VS Code, I feel this would be very beneficial.

My initial thoughts: Should Blender instead just have an 'external text editor' user preference, since there really isn't a whole lot of integration that would need to occur to get VS Code working with Blender. The only thing I can imagine being a nice tight integration between them would be having a 'virtual directory' within the blend file which gets opened in VS Code though I'm not sure if this is actually possible. The alternative would be to have a directory containing the 'code' for your blend files, with sensible named folders.

When you open the project in VS Code, it will create a folder in the user defined directory (could be alongside the blend file) in VS Code and optionally set up the environment with whatever configuration files Python and PIP need to function.

TTNK Author

@christopher.cook: Exactly what I meant, just expressed in a much better way :)

I have to said that I mentioned VS Code just to have a parallel with Unity and Visual Studio and because VS Code is a quite powerful open source [sorta] IDE, easy to expand with plugins, but, really any text editor can do the job

1
CyanBC

This would make things easier, that's for sure. VS Code is MIT license so it should be OK. However VS Code by itself is 100MB and installed around 200MB. I'm not sure if that would make it to a standard distribution. It would be nice to have a developer install package that came with (or integrated easily) all the necessary packages to build a full featured blender.

TTNK Author

@Cyanbcbc-work: No, I'm not talking about including VS Code inside blender, I'm talking about making a bridge between the two with an extension for VS Code itself, like what already happens between Unity and Visual Studio. VS Code would have to be installed separately anyway, which also means no problem of any kind with the licensing. Also my idea is mostly for using the Blender's API and the pip package manager, not actually rebuilding the source cod in C/C++ (although it would be nice)

1
sidartalei

@pietrobelgioco: This I very much want. I already use vs code for all my other projects. Having an extension from blender would be great. I've tried with fake bpy modules but couldn't get it right.

lemepes

@Cyanbcbc-work: VS Code is not MIT : code.visualstudio.com/License/ . It is MIT only if you build it yourself