Linked Questions
45 questions linked to/from Why avoid bpy.ops?
23
votes
2
answers
68k
views
Set active object with python
I want something along the following lines:
...
39
votes
2
answers
15k
views
Python performance with Blender operators
In my script, I have for loop over many cube objects (~1000) and the treatment is very slow. Looking more in details, I notice that in the same amount of loops:
if ...
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"...
14
votes
3
answers
4k
views
Is there a way to calculate mean curvature of a triangular mesh?
So I've written a script which does this:
Before:
After:
The code is:
...
5
votes
1
answer
10k
views
Rendering a cube as png file using Blender's Python API
I am new to Blender. I create a cube and want to render it. Since, we are later going to do this for large number of shapes, we are working with Blender's Python API. I want to save this rendering as ...
11
votes
2
answers
3k
views
Rotation around the cursor with low-level python (no bpy.ops)
In order to optimize my script, I would need some help to perform a rotation around the cursor
(see Rotate object around cursor with Python)
With low-level python, that means, without ...
7
votes
3
answers
9k
views
Batch exporting of multiple objects into separate STL files
I have as scene with 45 objects, I am trying to write a script that will export all of the objects into separate STL files. Any ideas?
Here is a broken script I have right now:
...
6
votes
3
answers
5k
views
How can I delete keyframes and animation data for all selected objects?
I am trying to do as the title suggests: remove all keyframes and animation data from all selected objects.
I am just starting out with Python and add-on development so this has proven to be a ...
11
votes
1
answer
4k
views
Run an edit-mode operator on every object in the scene
I want to untriangulate every object in my scene with this script:
...
1
vote
1
answer
11k
views
Creating objects with a 'for loop' and setting each new one a keyframe within the 'for loop'
So I wish to have a script which creates an object then set's it keyframe at a frame, 'f', before creating another object and setting a keyframe at a new frame, say f+1. However it always sets the ...
3
votes
3
answers
636
views
Generate non-overlapping spheres having different diameters in a cube
I would like to generate a 'N' number of spheres having different diameters within a cube. The condition is that the spheres shall not overlap. I use the following code to generate spheres (random ...
3
votes
1
answer
4k
views
How can I add a collection using Python?
I'm new to Blender. Tutorial information as recent as January this year appears to be out of date and I can't figure out how to create a new collection and add an object to it. The most recent ...
6
votes
1
answer
837
views
How do I create 2 Edge Loops adjacent to selected Edge Loop?
I'd like to know if there are any techniques or addons available for creating adjacent edge loops in a mesh based on a selected edge loop. The functionality would be similar to the Offset Edge Loop ...
3
votes
2
answers
3k
views
How do I subdivide a cube via scripting?
I have an object named "Cube" selected, and I set the mode to EDIT via
cube = bpy.data.objects.get('Cube')
cube.select=True
bpy.ops.object.mode_set(mode='EDIT')
...
5
votes
1
answer
2k
views
knife_project in python
I am a blender noob trying to use bpy.ops.mesh.knife_project() in my script. It fails with the message:
RuntimeError: Operator bpy.ops.mesh.knife_project.poll() expected a
view3d region & ...