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

How to create a custom UI?

Designing an UI or Add-on is basically a combination of supplying Properties and the inheritance of built-in Type classes (Panel, Operator, Menu etc.). Properties Start by defining your Properties ...
p2or's user avatar
  • 16k
59 votes
Accepted

Blender 2.8 API, python, set active object

Use the view_layer Set ViewLayer.active to any object in view layer or None context.view_layer.objects.active = ob Note ...
batFINGER's user avatar
  • 84.5k
52 votes

How to install Pip for Blender's bundled Python?

First of all, pip is not part of Python so it doesn't come by default with Blender. It has to be installed for Blender's bundled Python even if you already have pip for some other version of Python on ...
B Newmark's user avatar
  • 1,230
49 votes

Using 3rd party Python modules

While blender's python doesn't come with pip installed, it does have ensurepip. That means that you can do something like this: ...
NAS's user avatar
  • 591
44 votes
Accepted

How to call a confirmation dialog box?

When calling an operator via bpy.ops.* without any execution context the execute() method of the respective operator runs by ...
p2or's user avatar
  • 16k
44 votes
Accepted

TypeError: Element-wise multiplication: not supported between 'Matrix' and 'Vector'

Blender 2.8+ Matrix multiplication The question code method was in place for Blender <=2.79.9. Blender has since adjusted its mathutils module, replacing the ...
batFINGER's user avatar
  • 84.5k
43 votes
Accepted

How to add empty object not using bpy.ops?

This is possible by placing None as the object data: ...
TLousky's user avatar
  • 16.1k
35 votes
Accepted

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

Methods 1. List comprehension As mentioned by Pycoder in the comments below, using operators is often slow. So a quicker and simpler (and X2 faster) method to get all the verts that belong to a ...
32 votes
Accepted

Techniques for modeling a network of blood vessels

This is a nice case of how node based geometry generation can create crazy stuff. First off, you'll never guess who this is in the following Blend file: You will need the latest iteration of ...
aliasguru's user avatar
  • 11.2k
32 votes
Accepted

How to use Keyframes and the Python API programmatically?

Figured it out! Here's how to use the Python API to set it: ...
Julian's user avatar
  • 601
24 votes
Accepted

Add modifier to selected and another to active object

I'd suggest not using modifier add operator and use modifiers.new(name, type) instead. Avoids hassle of changing the active object and also if using the op to add ...
batFINGER's user avatar
  • 84.5k
23 votes
Accepted

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

There is an operator to do exactly this. it can be called from Python or accessed from a menu. Select the objects you wish to put in the camera view. View -> Align View -> Align Active Camera ...
ideasman42's user avatar
  • 47.5k
23 votes
Accepted

Is it possible to make a sequence of renders and give the user the option to cancel the process through the UI at any given time?

Yes! This is possible. I finally managed to get it to work in a loop. The current solution allows to cancel the operation with the X button in the Info Window and the ESC key. The images are rendered ...
Chaos's user avatar
  • 622
23 votes
Accepted

Clear Custom Split Normals Data on all objects

...
Raffia16th Blaze's user avatar
23 votes
Accepted

Converting code to work in blender with sliders

Fragment Shader Solution If we multiply the normalized polar angle by some number representing the number of strips and take its modulo with 1, it will give us a number of sub-normalized polar angle ...
Omar Emara's user avatar
  • 22.6k
22 votes

Where does console output go

Here is my script which redirects the print() function to all open python console windows. import bpy def print(data): for window in bpy.context.window_manager.windows: screen = window....
TheMindVirus's user avatar
21 votes

Selecting an object via scripting?

I'm just doing my duty here. Quick answer that works in 2.8: ...
user875234's user avatar
19 votes

How to create a custom UI?

Modified version -- for blender 2.80 ...
Daniol Dan's user avatar
19 votes

Techniques for modeling a network of blood vessels

I once created a blender addon as a part of my bachelor thesis about neuronal structures, which computes spanning trees using particle systems. You could use this to generate 3-dimensional tree ...
Parkuhr's user avatar
  • 826
19 votes

How to open system console to get output from Blender on Mac OS 10?

Right click on the Blender icon in the Applications folder and select "Show Package contents". Make an alias of Contents/MacOS/Blender by right clicking and ...
user007's user avatar
  • 536
19 votes

How do I get a mesh data-block with modifiers and shape keys applied in Blender 2.8?

Just tested batFINGER's solutions. It's pretty convoluted and you have to call bm.clear() every time the mesh updates before calling the last two functions. It works but really doesn't feel like the ...
Somebody285's user avatar
18 votes

2D solidify. Is it possible?

The easy way, which requires a bit (just a bit) of manual work: Install "Edit Tools 2" and "Loop Tools" addons. They're both available in basic blender 2.79/2.79a, so just find them in addons and ...
Alexander Podgayko's user avatar
17 votes
Accepted

Easy way to run python script in blender python console?

In Blender 2.80 and higher, you can use as_module(). In the above example, an unsaved text editor shows this code: ...
emackey's user avatar
  • 2,756
17 votes
Accepted

Animation nodes for geometry line art?

FreeStyle Edge Mark Animation Nodes have a node Splines From Edges that takes a list of edges and vertices an returns splines that represents those edges. All we have to do is filter the edges by ...
Omar Emara's user avatar
  • 22.6k
17 votes
Accepted

How can I create a mathematically correct arc/circular segment?

Add Primitive Arc Operator The theory is well covered here Calculate the radius of a circle given the chord length and height of a segment The ...
batFINGER's user avatar
  • 84.5k
17 votes

'bpy_prop_collection' object has no attribute 'link'?

If you are interested: As of Blender 2.8x SceneObjects.link(object) is gone due to the new collection system. You can use ...
brockmann's user avatar
  • 12.6k
16 votes
Accepted

How do I get the correct context for Python operators?

After looking through the api documentation, it does not appear that there is a direct way to know which contexts an operator will work in. Therefore, one way to determine this is to call an operator'...
David's user avatar
  • 49.4k
16 votes
Accepted

How to get the collection an object belongs to?

Object.users_collection property returns a tuple containing all linked collections: ...
brockmann's user avatar
  • 12.6k
16 votes
Accepted

How to list all collections and their objects?

You can access all collections through bpy.data.collections. The objects within the collection (and child collections) are given by ...
Robert Gützkow's user avatar
  • 25.7k
16 votes

`pip install bpy` Not Working (LookupError: unknown encoding: future_fstrings)

You are missing the future-fstrings package. I'm not sure why it doesn't install automatically but a simple pip install future-fstrings should solve this.
tbizzy0808's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible