Questions tagged [bpy]

`bpy` is the Blender Python API, used for scripting Blender plugins.

bpy is the Blender Python API, used for scripting Blender plugins. This tag should be used for help with Blender plugins written in Python.

Resources

94 questions
22
votes
3 answers

Blender 2.6: Select object by name through Python

How do you select objects by name through Python in Blender 2.6? In 2.4-2.5, one could simply use: bpy.ops.object.select_name("OBJECT") ... but this has been discontinued in 2.6, to be replaced by what? In 2.6, one can get the currently selected…
Jollywatt
  • 1,382
  • 2
  • 12
  • 31
16
votes
1 answer

Opening .blend files using Blender's Python API

I'm trying to make an automated build system for Blender 2.73 which reads XML files with lots of paths, opens the files one by another and then renders them. I'm using the following code in order to open: bpy.ops.wm.open_mainfile("file_path") My…
user3684240
  • 1,420
  • 2
  • 12
  • 18
5
votes
1 answer

ImportError: No module named 'bpy'

I am getting Error ImportError: No module named 'bpy' in Blender console. I am importing bpy module inside Blender console but still getting the Error. After long Googling I found that no one is getting the same error inside Blender. Using Blender…
Minn Trih
  • 51
  • 1
  • 1
  • 3
4
votes
2 answers

Control blender from python script outside of blender

i have a GUI made in pyside that render a blender file. This GUI have a resolution options to control this before render scene.... i have this code in PyCharm, i need to run this code without open blender. if resolutionWidth != 0: …
4
votes
1 answer

Pixels retrieved from Viewer Node within Blender are darker than the actually rendered image... Why?

I am trying to create a pipeline in which I first render an image using the blender python API (I am using Blender 2.90) and then perform some image processing in python. I want to fetch the image directly from blender without first writing the…
4
votes
1 answer

Selected vertex did not highlight in Blender 3D

I've made a Cube in Blender. Using Python I did enter EDIT mode and selected one vertex: import…
user3052391
  • 105
  • 2
  • 10
3
votes
1 answer

How to use the rotate operator on Blender Python if you execute the script on the background?

I am importing a model that consists of multiple individual meshes. Right after import (where everything is selected), I want to rotate the imported selected objects based on a [X, Y, Z] angle parameter. Also I want to run the script as a blender…
zackper
  • 125
  • 7
3
votes
5 answers

Cannot install package bpy using pip

Problem description: In VS Code, run the command pip install bpy (as indicated in https://pypi.org/project/bpy/) and get the following error message: PS C:\Users\(...)\Local\Programs\Python\Python38> pip install bpy Collecting bpy Using cached…
Filipe Rei
  • 53
  • 1
  • 1
  • 5
3
votes
1 answer

How to attach multiple mesh nodes to one object in blender?

I try to import 3d objects from one game (IGI 2: Covert Strike) into blender. Ingame format have a one common vertex buffer, where are stored all vertices from multiple meshes. Also have list of structs used to declare meshes, range of used vertices…
Artiom
  • 153
  • 1
  • 6
3
votes
0 answers

Import python package with shared library

I have compiled Blender as a python module: ant@asus:~$ ls -l /home/ant/.local/lib/python3.6/site-packages/bpy/ drwxrwxr-x 3 ant ant 4096 Jun 6 14:44 2.79 -rwxrwxr-x 1 ant ant 64221200 Jun 6 14:44 bpy.so If I run python from package folder -…
k.antipov
  • 41
  • 4
2
votes
1 answer

Accessing C pointers to vertices in Blender's Python API

I'm currently making a render engine in C and C++ for Blender. I want to access the vertices of a mesh from C via a pointer, to reduce the time spent in Python and avoid unneeded data duplication. I am aware that objects derived from the ID class,…
Elzaidir
  • 891
  • 6
  • 13
2
votes
0 answers

Blender as python module (bpy) installation not working correctly in docker virtual environment using jupyter

I follow the instructions here to generate a bpy wheel for Python installation. Environment: Python 3.10 (blender 3.6 requires) I am able to correctly install the wheel on my docker container and virtual environment on it. Running "locally" on…
vwertuzy
  • 171
  • 1
  • 2
  • 12
2
votes
1 answer

bpy.ops.sequencer.view_all() poll fails

I ask for help because I literally have no idea what I have to do for this. I'm bangin my head for 2 days and I have to admit that I just dont get it... I need a script to set the view in the sequencer to bpy.ops.sequencer.view_all() (or similarly:…
lucanapo
  • 59
  • 1
  • 1
  • 6
2
votes
1 answer

how to run bpy callback on workspace tools change

How to add a pre-draw hook to current context workspace.tools change? I attempted to get there using bpy.types.SpaceView3D.draw_handler_add(...) which as it runs on every draw, checks if workspace.tools changed, and if it changed, run my callback,…
ThorSummoner
  • 16,657
  • 15
  • 135
  • 147
2
votes
2 answers

Render using a blender script in google colab

I'm trying to run a script in blender, using the GPU available from google colab pro. I use the following code to install and configure Blender: import os os.environ["LD_PRELOAD"] = "" !apt remove libtcmalloc-minimal4 !apt install…
Lorenzo
  • 51
  • 4
1
2 3 4 5 6 7