As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [python]

Python is an object-oriented programming language. In Blender, it is used as a general purpose scripting language and to create add-ons to extend Blender's functionality.

Filter by
Sorted by
Tagged with
20 votes
3 answers
12k views

Is it possible to print to the Report window in the Info view?

I wonder if it is currently possible to print or send messages to the Report window in the Info view? this would be quite useful sometimes.
zeffii's user avatar
  • 39.2k
20 votes
4 answers
13k views

What programming languages can I use in Blender?

What version of Python does Blender use and are other languages available? Also, does Python work the same in Blender as when you write console applications or when working with Pygame or are there ...
20 votes
2 answers
39k views

How to rename selected objects using python?

I want to rename a large number of items. Doing so manually could take quite some time. I want to use python to rename the object. To find out the python command for renaming I renamed an object ...
Vader's user avatar
  • 14.5k
20 votes
4 answers
40k views

How to get Python multiprocessing module working on windows?

I am trying to run a script within Blender that utilizes multiprocessing module. According to documentation it is possible to use it ( see note at the end of "...
elmo's user avatar
  • 732
19 votes
4 answers
25k views

How to make object A a parent of object B via Blender's Python API?

I have two objects each of them hold in a variable. Now I want to parent them so object A is the parent of object B. How can I ...
Miguellissimo's user avatar
19 votes
1 answer
10k views

Controling compositor by python

I've been looking at the python code loging of Blender. But in there things get loged as mouse clicks. What i like to do is combine a few images into a larger one using compositor, but i need control ...
user613326's user avatar
19 votes
4 answers
9k views

How can I store and retrieve a custom list in a blend file?

I am trying to create a script that will allow me to generate a list and store it in the blend file. The list starts out blank and then strings get added to the list, resulting in: ...
Ray Mairlot's user avatar
  • 28.8k
19 votes
1 answer
8k views

Finding vertices in a Vertex Group using Blender's Python API

Is there an easy way to get the vertices in a vertex group? The only way I've found is pretty brute-force - e.g., to find the vertices of object obs[i] in group "e"...
Jabberwock's user avatar
19 votes
1 answer
11k views

How to check if two meshes intersect in python?

I need to check if two meshes intersect or not. At the moment I have some python code to find intersections of world axes aligned bounding boxes, next step would be to implement check for mesh ...
Lissanro Rayen's user avatar
19 votes
1 answer
6k views

What do new bpy class naming conventions in Blender 2.80 actually mean?

What are the new class naming conventions in Blender's 2.80 Python API for add-ons? It says here: This constraint applies to the bl_idname of each class (or the ...
Martynas Žiemys's user avatar
18 votes
2 answers
56k views

Set active object with python

I want something along the following lines: ...
clankill3r's user avatar
18 votes
6 answers
18k views

Python - Set material to material slot

I am using the Blender Internal render engine. I have an material slot with no material assigned to it. How can I assign a material to a slot using python? This should work in edit mode as well. ...
Vader's user avatar
  • 14.5k
18 votes
8 answers
3k views

How to find the number of loose parts with Blender's Python API?

I want to find out how many loose parts a mesh has using Python, i.e. write a function that takes a mesh object as an argument and returns an int. So far I haven't found a way to access this ...
Tim Ayres's user avatar
  • 283
18 votes
2 answers
32k views

create mesh then add vertices to it in python

I would like to create a mesh, then interactively add vertices (afterwards, possibly through a loop) to it through python. Is that possible? I can't find enough info from other answers to really get ...
Jono's user avatar
  • 183
18 votes
3 answers
19k views

How to get keyframe data from python?

I am looking for help on how to export armatures and their animations in a custom export script. I wish to have an animation format similar to BVH, i.e. a bunch of ...
rspencer's user avatar
  • 283
18 votes
2 answers
5k views

Is it possible to make a modifier with a python addon?

Is it possible to make python addon as a modifier? I just would like to make some deformation modifiers. But I know only python.
mifth's user avatar
  • 2,301
18 votes
1 answer
13k views

How can I use a Python script to get the transformation of an object?

How can I use a Python script to obtain the exact coordinates of an object? I have not been able to find out how to do this in the documentation.
Qu0rk's user avatar
  • 379
18 votes
1 answer
7k views

Proper way to show users error info in the UI for addons [duplicate]

Are there standardized features in the python API for displaying the popup and error message that users typically see in Blender when they're not doing something the right way? Trying to apply a ...
Qutorial's user avatar
  • 3,232
18 votes
1 answer
6k views

Using Blender for plotting graphs?

While gnuplot is serviceable and matplotlib is a popular choice for Python developers, I wanted to use Python for plotting some simple graphs (matplotlib had some issues installing on my system, with ...
ideasman42's user avatar
  • 46.5k
18 votes
3 answers
762 views

Select individual hairs with Python

Is it possible to select specific particle hairs or hair keys in Blender with Python? I'm writing a script on Blender 2.73a which involves finding hairs in a system by their index and applying the ...
laymouse's user avatar
  • 181
17 votes
6 answers
18k views

Rotate objects around their origin along a global axis (scripted) without bpy.ops

I have read so much about Blender rotation in the last two hours that my head is spinning, but I can not understand how to rotate strictly in global coordinates without using ...
uhoh's user avatar
  • 2,657
17 votes
3 answers
19k views

How can I get the camera's projection matrix?

As asked. I need a way to get the projection matrix of the active camera, via python. EDIT: I think this question is different from the one asked here, because getting a matrix is different from ...
Goran Milovanovic's user avatar
17 votes
3 answers
13k views

Align Object to Vector using python

I am trying to rotate an object using python, inline with a vector which gives me the direction I want (based on the difference between the last two coordinates of the curve I generated). I therefore ...
Batwam's user avatar
  • 325
17 votes
1 answer
5k views

How can I get a list of the installed addons using the API?

How can I get a list of the installed addons and the version number so I can print out and use as a simple reference when checking for updated scripts? I've looked at ...
askinner432's user avatar
  • 1,055
17 votes
1 answer
11k views

How do I create a new object using Python in Blender 2.80?

As part of an existing add-on, I'm trying to create an object and add it to the scene using Python. I followed a Blender Cookbook tutorial found here: Three ways to create objects. I use the following ...
Justin's user avatar
  • 1,962
17 votes
1 answer
1k views

How to create submenus with dynamic content?

I am trying to loop over all the cameras in my scene to populate a menu, and be able to access properties of each camera from the submenu of each menu item. For the minute, I'm just trying to get it ...
Ray Mairlot's user avatar
  • 28.8k
17 votes
1 answer
8k views

How to switch rendering engine via python script

I managed to compile Blender as a Python import module. When I do bpy.ops.render.render(write_still=True) it renders with cycles. How can I render by using Blender ...
ikel's user avatar
  • 1,213
17 votes
1 answer
3k views

How to run an external command, showing its progress without locking Blender? (Escape to cancel for eg)

Currently if you run an external process from Python the command and locks Blender until it finishes, eg:subprocess.check_output(["sleep", "2"]). Whats the best ...
ideasman42's user avatar
  • 46.5k
17 votes
3 answers
2k views

Add a custom curve mapping property for an add-on?

Question The title says it all. I want to be able to make this in Blender's UI, and sample it at specific points from an add-on: Problem There is very insufficient documentation on this, and I can't ...
JakeD's user avatar
  • 8,307
16 votes
3 answers
15k views

Update viewport while running script

I have a script, which creates multiple objects through a loop. However, the script freezes the viewport until it is done. Instead, I would like every object to be seen in the viewport one by one as ...
dwitvliet's user avatar
  • 409
16 votes
2 answers
7k views

Switch to vertex, edge, face mode in edit mode via python

Is it possible to switch to vertex mode (and edge, face mode) via python. I know I can toggle between object mode and edit mode in python with ...
Miguellissimo's user avatar
16 votes
3 answers
13k views

Is it possible to use bpy.props.PointerProperty to store a pointer to an object?

If the user renames an object, the reference via string key is lost. Is it possible to store a pointer to an object in a property assigned to a class of bpy.types ...
pink vertex's user avatar
  • 9,776
16 votes
4 answers
5k views

Workflow for developing add-on/script

I'm trying to figure out a good workflow for developing scripts and add-ons in Blender. Here's what I'm currently doing as I try my luck with a PyNode add-on: Open blender Create a text editor panel ...
ajwood's user avatar
  • 9,951
16 votes
6 answers
14k views

How to find if a point is inside a mesh?

I need a python script that would help me determine if a point is inside a cylindrical mesh. I tried the .pointInside(point, selected_all=False) but it is deprecated in the newer versions of blender ...
NewToBlender's user avatar
16 votes
1 answer
29k views

Duplicating a mesh object [duplicate]

I would like to duplicate a mesh object, but on a particular object. Right now this is working: ...
Raspberry's user avatar
  • 405
16 votes
3 answers
23k views

How do I select specific vertices in blender using python script?

I have created a plane and have applied loop cut and slide twice horizontally and once vertically( using python script). With this done, I intend to select the top two corner vertices using python ...
Gabriel's user avatar
  • 591
16 votes
2 answers
10k views

How to get Blender's version number from Python?

How do I go about programmatically getting the Blender version number? Example: If I am running Blender 2.76, how would I get the version number from the python console?
Greg's user avatar
  • 583
16 votes
3 answers
12k views

How to get world-space matrix of any pose bone?

Is there a command for getting world-space matrix of pose bones, same as obj.matrix_world for objects? I found pose_bone.matrix, ...
Roman Volodin's user avatar
16 votes
2 answers
5k views

How can I navigate the viewport using Python?

Normally, with most actions that you want to script with Python there is a pop-up tooltip that shows you the function that you want to use. However, for viewport navigation there are no pop-ups, you ...
fouric's user avatar
  • 3,231
16 votes
2 answers
931 views

What's the most reliable way of converting a material into reusable code blocks?

I'd like to convert certain materials into executable python code without having to re-code them from scratch each time. While doing some initial experimentation on the principled shader, I realized ...
brockmann's user avatar
  • 11.8k
16 votes
2 answers
12k views

How to automatically fit the camera to objects in the view?

I'm using blender to render avatar and avatar accessories on a website, however there is a problem, when a hat, or accessory is made a bit large, the it doesn't fit in the viewport, is there anyway to ...
slixxed's user avatar
  • 163
16 votes
1 answer
3k views

How to pass multiple operator properties via UI layout?

Basically, I want to have a single operator which can do multiple things, based on some attributes values. ...
Polosson's user avatar
  • 6,454
16 votes
1 answer
5k views

Insert keyframe on an object's custom property with Python

How can I add keyframes to custom properties with python? Usually, I can use the function object.keyframe_insert(data_path="location") but I couldn't find the ...
Salvatore's user avatar
  • 737
16 votes
2 answers
3k views

How to add a group into a node tree with Python

How do I add an already created node group into a node tree? I have found that this works: ...
BlendingJake's user avatar
  • 2,547
16 votes
1 answer
14k views

How to read vertices of quad faces using Python API?

Preferable in object mode. I have a mesh I know is made of quads only. I want my script to iterate through each quad and do something with the coordinates of each of the four vertices. I have read ...
Hatoru Hansou's user avatar
16 votes
3 answers
5k views

How to get Blender 2.80 to render through an ssh connection? [Minimal working example provided]

I am using Blender 2.80 on my local machine and the machines I am connecting to via ssh. My local machine is Ubuntu 18.04. I hope to use Blender to programmatically generate images as part of my code ...
ComputerScientist's user avatar
16 votes
3 answers
2k views

How can I remove a linked library with Python?

Load and add linked object I'm working on an add-on. The purpose is to link and un-link groups from another blend file. Thanks to stack exchange and the Blender documentation this works pretty well. ...
Monster's user avatar
  • 8,148
16 votes
1 answer
4k views

python get "image" of 3D view for streaming / realtime EEVEE rendering

[SEE Edit #7 at the bottom for official, final question] I know its possible to take a screenshot with python of a particular window (take screenshots programmatically in bge?), but is there a better ...
B''H Bi'ezras -- Boruch Hashem's user avatar
15 votes
3 answers
36k views

How do you get an object's position and rotation through script?

I'm working on a project that requires me to get some of the position and rotation values to give to an Arduino via pyserial, but after sifting through the Blender documentation I can't find how to ...
Carrot M's user avatar
  • 153
15 votes
2 answers
14k views

Add modifier to selected and another to active object

I am trying to set up an operator to use the BoolTool after I set a position and modifier on Selected object and a different one on the Active object. I basically need to move the selected object up ...
Craig D Jones's user avatar