Hi fellow python coders,
I so wanted code completion when tinkering with blender python api that I took the plunge and repurposed sphinx_doc_gen.py - script used for the api docs generation - to generate .pypredef files for Pydev. So if it’s in the docs, code completion should be now available.
./blender --background --python /path/to/pydev_pypredef.py
This will generate, alongside the script, a folder named pypredef_bpy_api_version.
This folder contains the necessary files to enable code completion for bpy, blf and mathultils modules within pydev.
- Window > Preferences…
- Preferences > Pydev > Interpreter-Python
- Python Interpreters > Predefined > New…
- Select Folder then Apply
- bgl, aud and bge modules are not currently supported
- code completion is not exhaustive, parts of the api are not documented. In doubt, check the online docs
obj = bpy.context.active_object # code completion will also work for obj
obj = bpy.context.selected_objects # code completion doesn't work for obj. # but you can assert the type of obj assert isinstance(obj,bpy.types.object) # and now code completion will work as expected for obj
The attached archive contains:
- pydev_pypredef_gen.py : script to generate the .pypredef files
- a folder containing pre-generated .pypredef files for the python api corresponding to the 2.57b release