Fake bpy modules (For Code Auto-completion on IDE)


(Nutti) #1

Hi,

Blender does not python API as python files, so only few APIs can be completed code automatically by IDE (PyCharm, Eclipse).
Therefore, I made a fake python modules for a code auto-completion on IDE.

Supported Blender Version: 2.79

If you want to try the fake modules, copy whole files on https://github.com/nutti/fake-bpy-module/tree/master/modules/2.79 to your project directory.

I will show you an example in PyCharm.


Any requests and comments are welcome.

Have a fun for bpy coding!!


(cmomoney) #2

You’re so awesome for this. :yes:

In Pycharm you can add it as a “Path For The Selected Interpreter”, so you don’t have to copy folder to your project directory.


(rombout) #3

Does this work with Brackets?

Do i need to follow the steps in the gitHub page and then add "from gen.py import * orso? Not sure what to do with the gen.py file


(antoni4040) #4

No homo, but I love you…


(Cyaoeu) #5

Interesting addon(?)! It seems like there’s some stuff missing though, like scene, data, things under context.


(Nutti) #6

@cmomoney

Thanks.
You are right.

@rombout

sorry, the procedure in GitHub is for module generation.
if you want to fake bpy module, you only need to add modules on https://github.com/nutti/fake-bpy-module/tree/master/modules/2.79 to the path on IDE’s project .

@antoni4040

you are welcome :slight_smile:

@Cyaoeu

ah…, you are right.
but we can not get these things from Blender’s documentation.
If there is idea to get them, please tell me…


(Cyaoeu) #7

Yeah I’m not sure either. Besides it’s pretty obvious that stuff like context won’t work because there’s no Blender scene anyway. :stuck_out_tongue: Still it would be interesting if you could “fake” objects too. But I guess I do things like this in the python console anyway (and then copy paste) so it doesn’t matter too much.


(Nutti) #8

@Cyaoeu

yes, it’s future tasks about it.
Anyway, thanks for your pointing out.


(rombout) #9

I will need to dive into this and see if this is helpfull.

I dont compelte understand what the benefit of this addon is. Does this addon autocomplete you code in PyCharm and also check for possible errors in the code and functions, classes etc etc?


(Nutti) #10

@rombout

I dont compelte understand what the benefit of this addon is

No, it is not add-on.
it is modules for only add-on developers.

we can auto-complete add-on codes in PyCharm or VSCode.
I was in trouble about that there is no module which can auto-complete bpy code.
so, i use this modules for auto-completion and make the development faster.


(Pitiwazou) #11

We did something similar !

Pycharm is really great with template and auto complete !


(Cyaoeu) #12

Thanks, this worked great. Would have been easier with an english video though. :stuck_out_tongue:


(Nutti) #13

@pitiwazou

nice tutorial !!
my module can be adapted same way


(rombout) #14

I got it working now using Pitiwazou method. Quite nice actually, no i need to get used to PyCharm, i used brackets always. So i need to check how i can get my colors the same to that theme. Im almost there but some parts wont color.


(Pitiwazou) #15

Love Pycharm, templates makes life so easy !

I use Script Watcher addon to update in blender on single file addons, don’t really work on multi files addons.
F8 works too but we have a lot of error messages from other addons.

3 solutions :

1 - Restart blender
2 - Use script watcher or F8
3 - Use F8 on clean blender with no addons


(rombout) #16

Yea i noticed the error with script watcher. I got a addon which consist of multiple script, this causes for errors about some script which cant load. So i guess im back at using F8, also causes errors sometimes for km stuff. So restart is only option. Was always working like that so i had hoped this would work.

I need to start learning about all them plint and pep8 warning, its looks messy due to that. Some of those warnings arent relevant i guess


(alex_93v) #17

Don’t know why bu I can’t get it to work…



(JeromePuttemans) #18

Hi, I juste used the process discribed here : https://github.com/nutti/fake-bpy-module
but can you explain how to use these generated files in vs code for auto completion ?


(kabu) #19

About VSCode:

In your setting.json add the following line:

{
“python.autoComplete.extraPaths”: [
“/Path-to-the-bpy-definition-folder”
],

Mind the path is absolute. HTH.