Using clipboard in Blender

Copying objects to the clipboard is used in Blender in the same way as in all other applications: by pressing the Ctrl + c key combination, and pasting from the clipboard with Ctrl + v. However, an interesting feature of copying and pasting objects in Blender is that the system clipboard is not actually used.

Author: Andrej.

When pressing Ctrl + c key code in a 3D viewport area, the Blender API calls the view3d.copybuffer() operator.

We can call the copy operator through the Python API with the following:

When executing this operator, Blender creates a separate “copybuffer.blend” file in the system temporary directory.

In which places the selected objects from the current scene.

This is a common Blender file, and it can be opened for viewing and editing.

The objects saved to the file are not added to the scene, they are only appended to the Objects list. So we can watch them in the Outliner, but not in the 3D Viewport.

When the user presses the Ctrl + v key combination, the view3d.pastebuffer() operator is called.

It can also be called via the Python API

The “autoselect” parameter is responsible for the fact that the pasted objects will be immediately selected, and the “active_collection” parameter – that they will be added to the currently active collection.

When executing tis operator, Blender simply imports objects into the scene from the copybuffer.blend file previously saved to the temporary directory.

In this way, objects are copied and pasted without using the system clipboard.

On the one hand, this method has some advantages – copying text or using the clipboard in other applications does not interfere with the copy/paste objects process in Blender. On the other hand, the copybuffer.blend file can be edited, and then, when pasting, objects that were not copied at all will be inserted. Or this file can be deleted, for example, if the user is configured to automatically clear the system temporary directory, and then the insert could not be performed at all.

0 0 votes
Article Rating
Notify of

0 Comment
Inline Feedbacks
View all comments