/blender-python-code-templates

repository of Blender python code templates for VScode extension

Primary LanguageJavaScriptMIT LicenseMIT

blender-python-code-templates

Python snippets for Blender python code.

GitHub repository link

Addon at VScode Marketplace

Blender addon for turning files/blender texteditor content into .json snippets

Snippets

Prefixes Description
info addon Blender addon info
license gnu GNU license
license mit MIT license
keymap item keymap item More Info
keymaps Register and unregister keymaps
menu Menu
operator Operator function class, without any imports or added functions
operator modal Modal operator function, without any imports or added functions
operator modal draw Modal operator draw function, without any imports or added functions
panel Panel
pie menu Pie Menu
register Register and Unregister Module
template addon Example of addon for adding object
template background job Example of script that shows how you can run blender from the command line (in background mode with no interface) to automate tasks, in this example it creates a text object, camera and light, then renders and/or saves it. This example also shows how you can parse command line options to scripts.
template batch Example of exporting each selected object into its own file
template bmesh Example of to get mesh representation for bmesh from edit-mode and updating it back after bmesh operation.
template bmesh Example of to get mesh representation for bmesh from active object and updating it back after bmesh operation.
template keyingset Example of generating Keying Set
template nodes Example of Implementation of custom nodes from Python
template driver Example of script defining functions to be used directly in drivers expressions to extend the builtin set of python functions.
template script Example of loading script relative to current blend file. This stub runs a python script relative to the currently open blend file, useful when editing scripts externally.
template gamelogic Example of gamelogic module. This module can be accessed by a python controller with its execution method set to 'Module'
template gamelogic Example of Simple gamelogic python script.
template gamelogic Example of gamelogic script this must be assigned to a python controller where it can access the object that owns it and the sensors/actuators that it connects to.
template operator Example of Template for file export operator, operator exports data from blender to .txt file
template operator Example of Template for file import operator, operator imports data from .txt to blender data
template operator Example of operator involving bmesh for creating and adding object to scene
template operator Example of Operator template for editing mesh UV's with bmesh
template operator Example of Blender modal operator function with imports, main function, register, unregister and testcall
template ui list Example of ui list template with adding it to blender with example panel
template ui list Example of simple ui list class with some filtering and bpy import
template ui menu Example of ui menu
template ui simple panel Example of ui panel class with import and register
template ui panel Example of ui panel class ui panel is created with examples of columns, buttons, rows, properties, with import and register,
template ui pie menu Example of 3d viewport pie menu
template dynamic enum This example script demonstrates a dynamic EnumProperty with custom icons.
template ui previews This example script demonstrates how to place a custom icon on a button menu entry.

Contribution Notes

If adding or editing a snippet's prefix or description, to keep from having to edit the above table, you can generate it using the documentation_helper script, just npm run table and it will write a TABLE.md file with the above table so you can just copy and paste it to here. The TABLE.md file has been added to the .gitignore so it won't get accidently committed.

Release Notes

0.9.0 beta

now snippets include templates for Blender python api

0.9.1

removed unnecessary newlines from templates.

0.9.4

added link to marketplace page to README.md added github repository to package.json added link to github repository to README.md added link to snippet generator addon github repository to README.md

new snippets: mit license


Thanks

Alan for his Blender VS Code Debugger addon, it's awesome!

Ideasman42 and others who have contributed to the Blender Wiki for providing instructions on how to build Blender as python module. Now my linter understands Blender.

Jacques Lucke's awesome Blender addon: Code Autocomplete.

Blender developers! for providing the awesome package known as Blender and the python code templates.