Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
21 votes
2 answers
43k 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.7k
21 votes
2 answers
701 views

Which modules are guaranteed to be present in Blender's Python?

Which modules are guaranteed to be included in Blender's custom Python build?
Forest Katsch's user avatar
21 votes
4 answers
20k views

Is there anyway to make blender print errors in the UI?

For some reason, sometimes error messages encountered while scripting are not printed in the info panel, only the message ...
gandalf3's user avatar
  • 157k
20 votes
1 answer
10k 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
20 votes
4 answers
14k 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
12k 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
20 votes
4 answers
41k 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
28k 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
2 answers
36k 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
  • 193
19 votes
1 answer
11k 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
3 answers
27k 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
  • 621
19 votes
4 answers
10k 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
  • 29.3k
19 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
  • 47.5k
19 votes
1 answer
7k 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
6 answers
20k 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,667
18 votes
6 answers
19k 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.7k
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
3 answers
21k 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
13k 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
  • 183
18 votes
2 answers
6k 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,351
18 votes
1 answer
14k 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
8k 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,322
18 votes
3 answers
786 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
3 answers
21k 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
14k 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
3 answers
15k 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,876
17 votes
2 answers
12k 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
  • 643
17 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
  • 10.1k
17 votes
1 answer
33k 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
  • 425
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,065
17 votes
1 answer
4k 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,564
17 votes
1 answer
12k 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
  • 2,012
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
  • 29.3k
17 votes
1 answer
9k 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,243
17 votes
1 answer
4k 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
  • 47.5k
17 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
17 votes
3 answers
3k 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,487
16 votes
3 answers
41k 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
  • 163
16 votes
3 answers
17k 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
16k 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
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
6 answers
15k 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
4 answers
3k views

Replace matrix @ vector list comprehensions with something more efficient

I'm looking to replace list comprehensions like the following with something more efficient and I was wondering if numpy can be used. ...
MACHIN3's user avatar
  • 807
16 votes
1 answer
5k views

What is the difference between items listed in bpy.ops bpy.data and bpy.context

When accessing items in a python script somethings are prefixed with bpy.data some with bpy.context and others with ...
sambler's user avatar
  • 55.4k
16 votes
2 answers
7k views

How could a single Python script run when Blender is started?

I would like to have a few globally available functions which should not not depend on a .blend file. Is there a place (A setup.py, ...
stacker's user avatar
  • 38.6k
16 votes
3 answers
14k 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,251
16 votes
2 answers
1k 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
  • 12.6k
16 votes
1 answer
6k 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
  • 757
16 votes
2 answers
4k 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,557