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.
2,653
questions
8
votes
2
answers
5k
views
How to call invoke_popup?
I just can't figure out how to create a custom popup which can receive data etc. What I want to do is let the user select one of the currently selected UV-layers and just hand that back to me. So I ...
8
votes
1
answer
14k
views
How to link/append with a Python script? [duplicate]
I want to append an element from another Blend file by a script. I found the Blender operator bpy.ops.wm.append which should do what I want. However, the API documentation is a bit unclear:
...
7
votes
1
answer
3k
views
How to get Color and Z-Depth from Viewer Node?
I read some article how to get the z-Depth values from the Viewer Node. So i created a scene with a camera and a Plane with distance z=2. Then i tried to get RGB values and also z-Depth with ...
7
votes
4
answers
5k
views
How to programmatically load a python script in Text Editor and launch it
With python API, is it possible to load a (new) python script in the Text Editor and then launch it (to automate things !) ?
I try this but it doesn't work :
...
6
votes
1
answer
5k
views
Getting the list of points that describe a Curve without converting to mesh
I've used mathutils.geometry.interpolate_bezier() in the past to create points for a curve using the bezier handle and knot coordinates.
from the docs:
...
6
votes
2
answers
3k
views
Python: assign custom tag to vertices
Is it possible to associate a custom tag with each vertex?
I would like to be able to number them...
I have an export script that dumps 6000 vertices to file, I then run a simulation that generates ...
6
votes
1
answer
6k
views
How to access node tree of a selected node group in python?
Scenario:
I have these two node group instances "Test 1" and "Test 2" containing image textures. Now I would like to modify nodes inside of a selected node group in python.
To ...
5
votes
1
answer
6k
views
How to create a button on the n-panel?
I would like to make a custom button on the N-panel.
I already went through blender's templates and amended the ui button script to 2.8 but I don't understand where and how I should implement my code ...
5
votes
2
answers
3k
views
How can I drive the Switch nodes True/False value?
In the compositor I would like to add a driver to the Switch Node. I want to watch a frame value from a VSE strip.
When the current frame count equals the Strip start frame I want to switch the node.
...
5
votes
2
answers
2k
views
How to get data and edit it on UV map edges?
I have a UV map. I want to get texture pixels around connected mesh sides like this (selected in pink and red):
or even on separated islands like this:
How to do such thing with Python Blender API?
...
5
votes
2
answers
11k
views
How can I add a checkbox in the tools UI?
So I want to add a checkbox to the UV/Image Editor tools UI
This is currently my code, You can see where I have commented "#Checkbox Here" and later on in the UpdateOperator I want to check whether ...
5
votes
3
answers
10k
views
How can I export my blender model as a python script
I am using Blender 2.77. When we select File > Export from the menu, the default export options Blender gives are .3ds, .fbx, .bvh, .ply, .obj, .x3d/.wrl, .stl, .svg...
5
votes
1
answer
3k
views
Is it possible to set the Output name based on the current Timeline marker?
I've got a scene with timeline markers. Example: "Bob", "John" etc.
I want to set the Output file name to match these markers, so that I can hit Render Animation and have Blender change the output ...
5
votes
1
answer
3k
views
Generate random ellipsoids
I have a problem to generate random ellipsoids inside a cubic space.
This is the script I wrote:
...
5
votes
1
answer
636
views
Handler-script updates in viewport but not in render
I'm completely stuck :-/
I've made a handler-script, that takes with every new frame a new line from the
text-editor and puts that line into the text-object in 3d-space.
It works absolutely fine - ...
5
votes
2
answers
2k
views
Blender gets very slow to draw a scene having large number of plane?
I have a very simple python script to generate planes in the scene. I want to generate 50000 planes in a scene, to compensate for unavailability of POINT primitive, so that i can render a point cloud. ...
4
votes
1
answer
486
views
Link selection between VSE strip and object?
My current workflow for a project I am working on uses empties in the 3D-View to more easily control properties of strips in the VSE via drivers. However sometimes it gets a little confusing which ...
4
votes
3
answers
5k
views
Python : Get selected objects in outliner
To get the selected object in viewport, we use :
bpy.context.selected_objects
But in outliner, if i select some objects there, then what is the python function to ...
4
votes
3
answers
2k
views
Is there a way to get a list of coplanar faces using Python?
Is there a way in Python to get a list of faces that are coplanar to a particular face similar to the way the command "Select Linked Flat Faces" works, but without actually requiring me to change the ...
4
votes
2
answers
3k
views
Store each animation frame as new object
Is it possible to store each animation frame as a new object? I searched quite a long time now on google and was wondering that I cannot find any information about this.
I just have a simple model ...
3
votes
2
answers
3k
views
Python: Bisect mesh into n parts, without separate 'LOOSE'
Using Python I want to split a mesh into tiles. All the solutions to this question rely on bpy.ops.mesh.separate(type='LOOSE'). But this leads to problems in the ...
3
votes
1
answer
2k
views
How to create a PyDriver in blender 2.7
I've heard of PyDrivers where you can put python code into a driver, & I'm wondering, how would you do that in blender 2.7x without resorting to a lower blender version?
Here's what I'd like to ...
3
votes
2
answers
580
views
Same Material with different key frames
Is it possible to have same (single) material object applied to different objects (mesh or curves) but have different key frames for each (mesh or curve)?
I want to fade-in my text (which is curve) ...
3
votes
3
answers
3k
views
How do I prevent object from moving when parenting object to a bone?
I've been trying different examples to parent an object to a bone without the object moving (aka keep_transform), but no matter what I try it always offsets:
...
2
votes
1
answer
2k
views
set a specified vertex color to black via python
how to set the vertex color in the center of the mesh to black and the rest of the vertices to red via python? a lot of the answers just tell me that i can color all the vertices in one face like that:...
2
votes
1
answer
611
views
is there a way to streamline scripting these shaders and modifier keyframes?
Here is a simple demo script for keyframes on shaders and modifiers for multiple objects. In the future there will be much more going on, so I want to know if there is an easier way to do these kinds ...
2
votes
1
answer
2k
views
How do I add keyframes to a newly created action with no associated objects?
So I'm writing an animation import script...
since animation bone names can differ from the armature's bones in question,
I want to create the actions and edit their group names manually, and then ...
1
vote
1
answer
731
views
Bake an fcurve with visual transforms
I want to duplicate an existing animation and bake it with visual transforms applied, something like what the default nla baker does. For simplicity's sake say I need to do this for a single bone. ...
1
vote
2
answers
2k
views
How to get indices of the faces to which a material has been applied, using Python?
I have many objects similar to this and I import them into the scene using bpy.ops.import_scene.obj(filepath='model.obj', split_mode="OFF") to do some renderings ...
1
vote
1
answer
1k
views
How do I get the deformed coordinate of a vertex with Python?
How might someone find the deformed coordinate via Python or otherwise when using a subdivision modifier with the 'show on cage' option?
For example, a subdivided cube with cage enabled and a vertex ...
0
votes
1
answer
769
views
Access Audio Strips Sample data in Python for a Cross-Correlation
I want to perform an Audio Cross-Correlation in Blender (like with numpy.correlate) to align two Audio Strips. But I can't figure out how to access the Sample Data of an Audio Strip inside Blenders ...
0
votes
1
answer
696
views
Changing active camera will yield an incorrect rendering (camera view not reflected)
I have defined a Blender class to help me abstract out details for rendering, object manipulation etc. I setup my scene using this class and put 12 cameras in it. Then I start rendering objects by ...
30
votes
9
answers
30k
views
Efficient way to get selected vertices via python (without iterating over the entire mesh)
What's the best/fastest way to construct a list of selected vertices for a mesh object in python?
I want to avoid iterating over every vertex in the mesh if possible, since that seems like a really ...
25
votes
2
answers
6k
views
Blender UI Multithreading Progressbar
The following question might've been asked several times, but I've found no satisfactory answer.
Short question:
How can I show progress of background task in Blender UI?
Explanation:
I have a ...
23
votes
5
answers
20k
views
How to know which object is using a material
How to know which object is using a material.
I know that a material is used 4 time -> picture under:
I'm searching a solution with python and I'm blocked here :
...
18
votes
2
answers
14k
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 ...
18
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 ...
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 ...
15
votes
2
answers
9k
views
Absolute path of files in Blender (with Python)
Functions such as os.path.exists(image.filepath) fail when Blender uses relative paths, This seems to be because Blender uses // ...
14
votes
2
answers
3k
views
Assign datablock to custom property
With bpy.props I can assign bool, int, float and string ...
13
votes
1
answer
9k
views
How can I separate a single object file into multiple objects based on closed geometry?
Let's say you have a single obj with a number of separate closed 3D geometries in it. For example's sake, imagine you have an obj called neighborhoodfirehydrants.obj...
13
votes
4
answers
19k
views
How to toggle visibible / selectable / renderable for multiple objects?
For quite long time, I was looking for a faster way to toggle (or toggle off) visible / selectable and renderable for many objects, as illustrated below:
I know we can do the relatively quick select ...
12
votes
2
answers
15k
views
How to add a UV Map to a Mesh Using Python
I've made a script that creates a mesh in Blender using a binary file containing mesh data. That works fine, but now I need to get textures on the mesh and I want to create a UV map from the UV data ...
12
votes
3
answers
7k
views
Possible to replay repetitive tasks using Python?
Is there a way to do a particular task manually, generate the code for it automatically and update that code to do some task repeatedly?
I'm looking for something like record macro functionality that'...
12
votes
2
answers
9k
views
Exporting UV coordinates
I'm having massive trouble exporting UV coordinates from Blender. I'm using the following code:
...
12
votes
2
answers
4k
views
Import object without bpy.ops.wm.link_append
Is it possible to import an object from a library file through Python without using bpy.ops.wm.link_append? I want an object to appear in ...
12
votes
5
answers
13k
views
How can I create a cylinder linking two points with Python?
I want to position a cylinder such that the center of one end is at (x0, y0, z0) and the center of the other end is at ...
12
votes
1
answer
10k
views
How to put together a driver with python
I'm trying to write a script to create the beginnings of a music visualizer but I'm having a hard time creating drivers to do it. My basic game plan is this:
Calculate frequencies and step sizes
For ...
12
votes
2
answers
8k
views
Incorrect matrix_world after transformation
This script changes the active object's location, it could also change the rotation or scale, it also prints the object's world matrix before and after changing the location.
...
11
votes
2
answers
18k
views
How do I stick an object to another objects vertex?
I just created a plane and added a wave modifier to it, to simply make it look like something fluid. Now, I have an Object that I want to place on the surface of this fluid plane. But how do I do that?...