Blender 2.83.7 LTS release
The Blender 2.83.7 LTS release is enabled for downloading on the official Blender site.
9 bugs fixed in this version.
The Blender 2.83.7 LTS release is enabled for downloading on the official Blender site.
9 bugs fixed in this version.
To completely remove the object from the scene through the Blender Python API do the following:
Open the “Text Editor” window.
How to delete object from scene through the Blender Python APIRead More »
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.
The Blender 2.90.1 release is enabled for downloading on the official Blender site.
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:
1 2 |
def cube_add_fnc(self, context): self.layout.operator('mesh.primitive_cube_add', text='', icon='MESH_CUBE') |
and add it to the window header:
1 |
bpy.types.VIEW3D_HT_header.prepend(cube_add_fnc) |
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.
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’
To create and add a camera to the scene with the Blender Python API we need to do the following:
1. Create a camera data-block
1 |
camera_data = bpy.data.cameras.new(name='Camera') |
2. Create an object and link it with the camera date-block, we created
1 |
camera_object = bpy.data.objects.new('Camera', camera_data) |
3. Add created camera-object to the scene
1 |
bpy.context.scene.collection.objects.link(camera_object) |
A new camera will be created in the current scene in its main collection.
Final code:
1 2 3 4 5 |
import bpy camera_data = bpy.data.cameras.new(name='Camera') camera_object = bpy.data.objects.new('Camera', camera_data) bpy.context.scene.collection.objects.link(camera_object) |
The Blender Python API provides the ability to append or link objects from another *.blend file to the current scene using the “append” command.
To append an object (for example – a mesh) from another .blend file, we need to do the following:
How to append an object from another blend file to the scene using the Blender Python APIRead More »
To register Blender to open *.blend files by double-clicking we need to:
Quickly registering Blender to open blend-files by double-clickingRead More »