We can get a list of all available shader nodes by their type.
To start, add any object to the scene, for example, a cube, create material for it, and delete all nodes. Here, in this material, we will display all the shader nodes available in Blender.
To add an operator to the area header, we can use the “append” and “prepend” functions specifying in its parameters the drawing function of the operator call button.
For example, to add an operator of adding the default cube to the header of the viewport (3D View) area, we need to define the operator drawing function:
The operator button will appear in the header of the viewport window.
Now we can view a list of all the functions that add operators to the area header by the “_draw_funcs” property of the “draw” method.
Python
1
2
bpy.types.VIEW3D_HT_header.draw._draw_funcs
# [<function cube_add_fnc at 0x000000000FC8B8B8>, <function VIEW3D_HT_header.draw at 0x000000000F9C0678>, <function draw_pause at 0x0000000011633A68>]
Note that the “_draw_funcs” property would be defined only if custom operators have been added to the area header. If custom operators were not added to the header, an error will be thrown:
AttributeError: ‘function’ object has no attribute ‘_draw_funcs’
In scripts and add-ons for importing-exporting files with formats that are not supported in Blender by default, we must give the user an ability to select files using the “FileBrowser” interface.
To open the file browser window, and after the user selects the necessary file, to return the path to it, we need to use the “ImportHelper” and the “ExportHelper” classes.
For add-ons development, sometimes it is necessary to use packages that are not included in the core set of the Blender Python interpreter. Most often, the dependencies you need are included in the Python Package Index (PyPI) and can be installed to Blender through the Pip package management system.
The Pip Package Manager is already installed in Blender. However, Blender does not allow us to install the desired packages in a common way with the “pip install package_name” command.
For objects rotation, we can use the “rotation_euler” property. This property is a list of three items, each of them corresponds to the rotation angle around the X, Y, and Z-axis. TheĀ otation_euler[0] contains the rotation angle around the X-axis, rotation_euler[1] – around the Y-axis, and rotation_euler[2] – around the Z-axis. To rotate an object we must set a rotation angle to the appropriate field of the property.
For example, to rotate an active object around the X-axis to the 90 degrees angle we must execute the following command: