So keep reading this manual, learn the great tool that Blender is, keep . – December Fire and smoke improvements, anisotropic. This manual is a good start, though it serves more as a reference. . – December Fire and smoke improvements, anisotropic shader for Cycles. Community · Manual · Tutorials · Python API · Developers Forum · · News · Jobs · Website · Contact · Open DataNEW. Follow Blender. Development .
|Genre:||Health and Food|
|Published (Last):||2 March 2013|
|PDF File Size:||8.40 Mb|
|ePub File Size:||3.89 Mb|
|Price:||Free* [*Free Regsitration Required]|
This tutorial is designed to help technical artists or developers learn to extend Blender. An understanding of the basics of Python is expected for those working through 265 tutorial.
To best troubleshoot any error message Python prints while writing scripts you run blender with from a terminal, see Use The Terminal. An addon is simply a Python module with some additional requirements so Blender can display it in blendr list with useful information.
Notice this addon does not do anything related to Blender, the bpy module is not imported for example. This is a contrived 2.5 of an addon that serves to illustrate the point that the base requirements of an addon are simple. Messages will be printed when enabling and disabling. The simplest possible addon above was useful as an example but not much else.
This next addon is simple but shows how to integrate a script into Blender using an Operator which is the typical way to define a tool accessed from menus, buttons and keyboard shortcuts. Click the Run Script button, all objects in the active scene are moved by 1. Rather than using bpy. In most cases these will be the same however in some cases operators will be passed a custom context so script authors should prefer the context argument passed to operators.
To test the script you can copy and paste this into Blender text editor and run it, this will execute the script directly and call register immediately. However running the script wont move any objects, for this you need to execute the newly registered operator.
Even though the addon above is a test, lets go through the steps anyway so you know how to do it for later. To install the Blender text as an addon you will first have maunal save it to disk, take care to obey the naming restrictions that apply to Python modules and end with a.
Now the addon will be listed and you can enable it by pressing the check-box, if you want it to be enabled on restart, press Save as Default. The destination of the addon depends on your Blender configuration. When installing an addon the source and destination path are printed in the console. You can also find addon path locations by running this in the Python console. More is written on this topic here: For our second addon, we will focus on object instancing – this is – to make linked copies of an object in a similar way to what you may have seen with the array modifier.
Now try copy this script into Blender and run it on the default cube. After running, notice that when you go into edit-mode to change the cube – all of the copies change, in Blender this is known as Linked-Duplicates.
Vector instances, a convenient class provided by the mathutils module and allows vectors to be multiplied by numbers and matrices. If you are interested in this area, read into mathutils.
Vector – there are many handy utility functions such as getting the angle between vectors, cross product, dot products as well as more advanced functions in mathutils.
Everything here has been covered in the previous steps, you may want to try run the addon still and consider what could be done to make it more useful. The two of the most obvious missing things are – having the total fixed at 10, and having to access the operator from space-bar is not very convenient.
There are a variety of property types that are used for tool settings, common property types include: These properties are handled differently to typical Python class attributes because Blender needs to be display them in the interface, store their settings in key-maps and keep settings for re-use. While this is handled in a fairly Pythonic way, be mindful that you are in fact defining tool settings that are loaded into Blender and accessed by other parts of Blender, outside of Python.
Operator properties are defined via bpy. These properties from bpy. There are many arguments you can pass to properties to set limits, change the default and display a tooltip. To find the identifier of a menu you can hover your mouse over the menu item and the identifier is displayed. For docs on extending menus see: In Blender addons have their own key-maps so blenfer not to interfere with Blenders built in manua.
In the example below, a new object-mode bpy. KeyMap is added, then a bpy.
Blender Reference Manual — Blender Manual
KeyMapItem is added to the key-map which references our newly added operator, using Ctrl-Shift-Space as the key shortcut to activate it. Notice how the key-map item can have a different total setting then the default set by the operator, this allows you to have multiple keys accessing the same operator with different settings. For API documentation on the functions listed above, see: Run the script or save it and add it through the Preferences like before and it will appear in the menu.
Directly executing the script multiple times will add the menu each time too. Addons can encapsulate certain functionality neatly for writing tools to improve your work-flow or for writing utilities for others to use. The example given in the tutorial is limited, but shows the Blender API used for common tasks that you can expand on to write your own tools.
Blender comes commented templates which are accessible from the text editor header, if you have specific areas you want to see example code for, this is a good place to start. Enter search terms or a module, class or function name.
Navigation index modules next previous Blender 2. Familiarity with the basics of working in Blender.
Be familiar with the concept of Python modules. Basic understanding of classes object orientation in Python. Suggested reading before starting this tutorial. Dive Into Python sections 1, 2, 3, 4, and 7. To give an example, here is the simplest possible addon. Note Rather than using bpy. Once the file is on disk, you can install it as you would for an addon downloaded online.
Note The destination of the addon depends on your Blender configuration. The method used for adding a menu item is to append a draw function into an existing class.
Note Directly executing the script multiple times will add the menu each time too.
Here are some sites you might like to check on after completing this tutorial. Blender Development Wiki – Blender Development, general information and helpful links. Blender Artists Coding Section – forum where people ask Python development questions.
Created using Sphinx 1.